@xzartsust
Учусь

Выводит две ошибки вместо одной (cooldown) discord.py?

Делаю вывод cooldown'а в командах и уведомления к ним.
Первая команда:
@commands.command()
@commands.cooldown(1, 30, commands.BucketType.member)
async def work(self, ctx):
    ...

@commands.Cog.listener("on_command_error")
async def cooldown_message_work(self, ctx, error):
    if isinstance(error , commands.CommandOnCooldown):
        member = ctx.message.author.mention
        await ctx.send(f"{member} you can only use this command once every 30 seconds! Try again in {int(error.retry_after)} seconds.")

Вторая команда:
@commands.command()
@commands.cooldown(1, 1200, commands.BucketType.member)
async def bake(self, ctx):
    ...

@commands.Cog.listener("on_command_error")
async def cooldown_message_bake(self, ctx, error):
    if isinstance(error , commands.CommandOnCooldown):
        member = ctx.message.author.mention
            m = (int(error.retry_after)//60)%60
            await ctx.send(f"{member} you can only use this command once every 20 minutes! Try again in {m} minutes.")

Проблема когда срабатывает cooldown в первой команде то и у второй тоже.
6036b5647f52e899253346.png
Как сделать что бы отправляло только один раз для одной команди?
  • Вопрос задан
  • 211 просмотров
Решения вопроса 1
@xzartsust Автор вопроса
Учусь
Нашел ответ. Надо использовать сog_command_error
async def cog_command_error(self, ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            member = ctx.message.author.mention
            m = (int(error.retry_after) // 60) % 60
            await ctx.send(f"{member} you can only use this command once every 20 minutes! Try again in {m} minutes.")
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы