Home > Enterprise >  How do you make a specific role able to use a slash command in Nextcord?
How do you make a specific role able to use a slash command in Nextcord?

Time:05-22

How do you make a specific role able to use a slash command in Nextcord?

I have found using @command.has_permissions(manage_messages=True) doesn't work when using slash command in Nextcord eg:

@bot.slash_command(description="Hello")
@command.has_permissions(manage_messages=True)
async def hi(interaction : Interaction):
    await interaction.send("Hello!")

I have tested this using alt accounts without the appropriate permissions and the command still works.

Is this a Nextcord bug or is there a different way to do this using slash commands?

CodePudding user response:

For slash commands, it's in application_checks. It seems.

from nextcord.ext import application_checks

@bot.slash_command()
@application_checks.has_permissions(manage_messages=True)
async def testperms(interaction: Interaction):
    await interaction.response.send_message('You can manage messages.')

Reference

  • Related