Я недавно создал бот-диск, используя discord.py. Я попытался сделать разрешения для некоторых команд. У меня есть эта функция команды теста:
@client.command()
@commands.has_role('Moderator')
async def cool(ctx):
await ctx.send("You are cool indeed!")
Как я могу вернуть сообщение (ошибку), если у пользователя нет роли «Модератор»?
Я уже пробовал это:
async def on_command_error(ctx, error):
if isinstance(error, commands.NoPrivateMessage):
await ctx.send("*Private messages.* ")
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send("*Command is missing an argument:* ")
elif isinstance(error, commands.DisabledCommand):
await ctx.send("*This command is currenlty disabled. Please try again later.* ")
elif isinstance(error, commands.CheckFailure):
await ctx.send("*You do not have the permissions to do this.* ")
elif isinstance(error, commands.CommandNotFound):
await ctx.send("*This command is not listed in my dictionary.*")
Но я ничего не получу от этого.