From e96fad8bf160ce9aabd26250e466451ca2d13c33 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 31 May 2021 16:07:21 +0200 Subject: [PATCH] real correction due to the new slash command whose commands were bugging if they had arguments --- src/cogs/fun.py | 6 ++++-- src/cogs/games.py | 4 +++- src/cogs/internet.py | 4 +++- src/cogs/school.py | 4 +++- src/cogs/utils.py | 22 ++++++++++++++++------ 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/cogs/fun.py b/src/cogs/fun.py index f8bc4b1..1f81b6d 100644 --- a/src/cogs/fun.py +++ b/src/cogs/fun.py @@ -119,14 +119,16 @@ class Fun(commands.Cog): return await self._love(ctx, user1, True) @commands.command(name='8ball', aliases=['8b', '8balls']) - async def _8ball(self, ctx, fromSlash = False): + async def _8ball(self, ctx, fromSlash = None): """Répond à ta question 🔮.\n ➡ Syntaxe: {PREFIX}8ball/8b⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" + if fromSlash == None: + fromSlash = False reponses=["c'est sûr.","il en est décidément ainsi.","incontestablement.","oui sans aucun doute.","tu peux t'y fier.","tel que je le vois, oui.","c'est le plus probable.", "cela montre de bonnes perspectives.","certes.","les signes indiquent que oui.","ma réponse est oui.","ta question est trop floue, réessaie.","redemandes plus tard stp.", "je ferais mieux de pas te le dire maintenant...","je ne peux pas le prédire actuellement :/","concentre-toi et redemande.","n'y comptes pas trop.","ma réponse est non.", "mes sources disent que non.", "les perspectives ne sont pas si bonnes...","c'est très douteux."] if fromSlash != True: - await ctx.message.add_reaction(emoji = '✅') + if fromSlash != True: await ctx.message.add_reaction(emoji = '✅') return await ctx.send(f"{ctx.author.mention}, {choice(reponses)}") @_8ball.error async def _8ball_error(self, ctx, error): diff --git a/src/cogs/games.py b/src/cogs/games.py index 95d7bdf..a420dbe 100644 --- a/src/cogs/games.py +++ b/src/cogs/games.py @@ -103,8 +103,10 @@ class Games(commands.Cog): await ctx.send(f"T'as pas trouvé {ctx.author.mention}... dommage, c'était {number}.") @commands.command(name='pileouface', aliases=['pf']) - async def _pileouface(self, ctx, fromSlash = False): + async def _pileouface(self, ctx, fromSlash = None): """Pile ou face.\n ➡ Syntaxe: {PREFIX}pileouface/pf""" + if fromSlash == None: + fromSlash = False if fromSlash != True: await ctx.message.add_reaction(emoji = '✅') return await ctx.send(f"{'Pile' if randint(0,1) == 1 else 'Face'} !") diff --git a/src/cogs/internet.py b/src/cogs/internet.py index 6a09f4a..9e4e40f 100644 --- a/src/cogs/internet.py +++ b/src/cogs/internet.py @@ -107,8 +107,10 @@ class Internet(commands.Cog): return await self._cat(ctx, True) @commands.command(name='dog', aliases = ['chien']) - async def _dog(self, ctx, fromSlash = False): + async def _dog(self, ctx, fromSlash = None): """Te montre un magnifique chien\n ➡ Syntaxe: {PREFIX}dog/chien""" + if fromSlash == None: + fromSlash = False if ctx.author.nick: name = f"{ctx.author.nick} ({ctx.author.name}#{ctx.author.discriminator})" diff --git a/src/cogs/school.py b/src/cogs/school.py index 8a53dd4..caf7557 100644 --- a/src/cogs/school.py +++ b/src/cogs/school.py @@ -76,8 +76,10 @@ class School(commands.Cog): pass @commands.command(name='getid', hidden = True) - async def _getid(self, ctx, fromSlash = False): + async def _getid(self, ctx, fromSlash = None): """Tuto vidéo sur comment récupérer l'ID d'un utilisateur/salon⁢⁢⁢⁢⁢""" + if fromSlash == None: + fromSlash = False if fromSlash != True: await ctx.message.add_reaction(emoji = '✅') return await ctx.send("Explication sur comment récuperer l'ID d'un utilisateur/salon : https://cdn.discordapp.com/attachments/640312926892195842/780802253258358834/GetID.mp4") diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 00fe9bf..a48ff1b 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -123,8 +123,10 @@ class Utils(commands.Cog): return await self._calc(ctx, calcul, True) @commands.command(name='syntax') - async def _syntax(self, ctx, fromSlash = False): + async def _syntax(self, ctx, fromSlash = None): """Informations pour bien éditer son texte.⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" + if fromSlash == None: + fromSlash = False syntaxe = "-----------------------------------------------------\n" syntaxe += discord.utils.escape_markdown("```Js\n") syntaxe += discord.utils.escape_markdown("//code en js (possible de remplacer 'js' par d'autres languages . adaptez le !)\n") @@ -165,8 +167,11 @@ class Utils(commands.Cog): syntaxe += "-----------------------------------------------------\n" syntaxe += discord.utils.escape_markdown(">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n") syntaxe += ">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n" - if fromSlash != True: - await ctx.message.add_reaction(emoji = '✅') + try: + if fromSlash != True: + await ctx.message.add_reaction(emoji = '✅') + except: + pass await ctx.send(syntaxe) @cog_ext.cog_slash(name="syntax", description = "Informations pour bien éditer son texte.") async def __syntax(self, ctx): @@ -210,8 +215,10 @@ class Utils(commands.Cog): return await self._memo(ctx, memo, True) @commands.command(name='infos', aliases = ['info']) - async def _infos(self, ctx, fromSlash = False): + async def _infos(self, ctx, fromSlash = None): """Donne des infos sur le bot.\n ➡ Syntaxe: {PREFIX}infos/info⁢""" + if fromSlash == None: + fromSlash = False appinfo = await self.client.application_info() embed = discord.Embed(color = discord.Colour.random()) @@ -244,8 +251,11 @@ class Utils(commands.Cog): embed.add_field(name = "Timezone", value = f"`{self.customTimezone}`") embed.add_field(name = "Version", value = f"`{version}`") embed.set_footer(text = f"Basé sur discord.py {discord.__version__}") - if fromSlash != True: - await ctx.message.add_reaction(emoji = '✅') + try: + if fromSlash != True: + await ctx.message.add_reaction(emoji = '✅') + except: + pass await ctx.send(embed = embed) @cog_ext.cog_slash(name="infos", description = "Donne des infos sur le bot.") async def __infos(self, ctx):