🥅 - Commands errors are now treaded in a better way.

This commit is contained in:
Florian SYLVAIN
2021-03-09 18:59:51 +01:00
parent 334cfce8fb
commit aaec2a4bdf
5 changed files with 129 additions and 173 deletions
+1 -12
View File
@@ -3,13 +3,12 @@ import asyncio
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
CD_ISSOU = 0
class OtherCmds(commands.Cog, name='Other commands'):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.command(ignore_extra=False)
@commands.cooldown(1, 2, commands.BucketType.guild)
async def issou(self, ctx, username: discord.User = None):
if username is not None:
@@ -31,19 +30,9 @@ class OtherCmds(commands.Cog, name='Other commands'):
if voice.is_playing():
await asyncio.sleep(1)
await voice.disconnect()
global CD_ISSOU
CD_ISSOU = 0
else:
await ctx.send('You or the targeted person are not connected to any channel.')
@issou.error
async def issou_error(self, ctx, error):
global CD_ISSOU
if isinstance(error, commands.CommandOnCooldown) and not CD_ISSOU:
await ctx.send(f'Please wait at least 2 seconds between each $issou.')
CD_ISSOU = 1
def setup(bot):
bot.add_cog(OtherCmds(bot))