“Cómo crear un rol y dárselo al autor discord.py” Código de respuesta

discord.py cómo darle a un usuario un rol

# 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

Cómo crear un rol y dárselo al autor 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

Respuestas similares a “Cómo crear un rol y dárselo al autor discord.py”

Preguntas similares a “Cómo crear un rol y dárselo al autor discord.py”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código