I want this command only usable for those who has one of my 3 specific roles.
@bot.tree.command(name = "addrole", description = "Rangadás", guild=discord.Object(id=my server's id))
async def addrole(interaction: discord.Interaction, member: discord.Member, role: discord.Role):
await member.add_roles(role)
await interaction.response.send_message(f"{member.mention}-ra ráadva: `{role.name}`!")
How can I make it? Thank you for your help!
I tried like this:
@bot.tree.command(name = "addrole", description = "Rangadás", guild=discord.Object(id=my server's id))
@commands.has_any_roles(id1, id2, id3)
async def addrole(interaction: discord.Interaction, member: discord.Member, role: discord.Role):
await member.add_roles(role)
await interaction.response.send_message(f"{member.mention}-ra ráadva: `{role.name}`!")
How this works
Using guild_permissions (under the member class) with type permissions we can check if a member has admin.
Code
Resources