“Discord.py Design função” Respostas de código

discord.py como dar uma função a um usuário

# If ctx is not defined and you are handling a message, use this code
ctx = await bot.get_context(message)

# This is the code needed to give a user a role
member = ctx.message.author # Member object that you want to add the role to
role = discord.utils.get(lambda role: role.name == "Role Name", ctx.guild.roles) # The role object
await member.add_roles(role) # Adds the role to the member
The Angriest Crusader

Adicionar papel discórdia .py

member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
Tyrannicodin16

Crie uma função com discord.py

@client.command(aliases=['make_role'])
@commands.has_permissions(manage_roles=True) # Check if the user executing the command can manage roles
async def create_role(ctx, *, name):
	guild = ctx.guild
	await guild.create_role(name=name)
	await ctx.send(f'Role `{name}` has been created')
HelloWorld

Adicionando papéis discord py

# If you need this in a bot command
@discord.ext.commands.command()
async def online(ctx):
  	guild_id = ctx.guild.id # the guild id where the command has been called
    role = discord.utils.get(bot.get_guild(guild_id).roles, id ="""The Id of the role you search""")
    await member.add_roles(role) # The role gets added to a given Member 
meppi

Como criar função discord.py

guild = ctx.guild
await guild.create_role(name="role name")
Clean Chinchilla

Discord.py Design função

@bot.command()
@commands.has_permissions(manage_roles=True)
async def giverole(ctx, member: commands.MemberConverter, Role: discord.Role):

  if Role in member.roles:
    await ctx.send("**`{0}` already has the `{1}` role!**".format(member.name, Role))
  else:
    await member.add_roles(Role)
    await ctx.send("**Successfully added the role `{0}` to `{1}`**".format(Role, member.name))
Gorgeous Guanaco

Respostas semelhantes a “Discord.py Design função”

Perguntas semelhantes a “Discord.py Design função”

Mais respostas relacionadas para “Discord.py Design função” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código