From a7c42594b505e26296ddfbbd455b3d28a05dd915 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 23 Aug 2021 12:47:06 +0200 Subject: [PATCH] handle error in whois command (no member found) --- src/cogs/utils.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 3d57b1e..64d1c76 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -206,7 +206,7 @@ class Utils(commands.Cog): embed.set_author(name = f"Mémo noté depuis {ctx.guild.name}", icon_url = ctx.author.avatar_url) embed.set_footer(text = f'📝 le {timestampScreen(intToDatetime(nowUTC()))}') await ctx.author.send(embed = embed) - + return await mySendHidden(ctx, fromSlash, "Tu viens de recevoir ton mémo !", delete_after = 5) @_memo.error async def _memo_error(self, ctx, error): @@ -241,7 +241,7 @@ class Utils(commands.Cog): text = len(text_channels) voice = len(voice_channels) nombreServeur = len(self.client.guilds) - + version = getActualVersion() dev = self.client.get_user(158260864623968257) @@ -253,7 +253,7 @@ class Utils(commands.Cog): lavalink = f", lavalink {lavalink}" else: lavalink = "" - + python = f" et Python {pyVersion[:5]}." embed.add_field(name = "Dev", value = f"[{dev}](https://discord.gg/Z5ePxH4)") @@ -352,22 +352,27 @@ class Utils(commands.Cog): if user[0].nick: nom = f"{user[0].nick} ({user[0].name}#{user[0].discriminator})" embed = discord.Embed(color = discord.Colour.random()).set_author(name = nom, icon_url = user[0].avatar_url) - + embed.add_field(name = "ID", value = user[0].id) - + embed.add_field(name = "Compte créé le", value = timestampScreen(user[0].created_at)) - + embed.add_field(name = "Âge du compte", value = ageLayout(getAge(user[0].created_at))) - + embed.add_field(name = "Mention", value = user[0].mention) - + embed.add_field(name = "Serveur rejoint le", value = timestampScreen(user[0].joined_at)) - + embed.add_field(name = "Est sur le serveur depuis", value = ageLayout(getAge(user[0].joined_at))) if fromSlash != True: await addReaction(ctx.message, 0) return await ctx.send(embed = embed) return await ctx.send(f"Tu mentionnes trop d'utilisateurs : `{ctx.prefix}whois [@membre]`") + @_whois.error + async def _whois_error(self, ctx, error): + """Error command handler""" + if "not found." in str(error): + await ctx.send(f"Le membre renseigné n'a pas été trouvé (mauvais ID ou aucun serveur en commun avec moi).") @cog_ext.cog_slash(name="whois", description = "Affiche les infos sur l'utilisateur.") async def __whois(self, ctx, user: discord.Member = None): """Slash command""" @@ -421,7 +426,7 @@ class Utils(commands.Cog): else: return await ctx.send(f"Désolé, mais tu as mis trop de possibilités (maximum : 20)") else: - return await ctx.send(f'Désolé, mais il manque des arguments : `{ctx.prefix}sondage "" "" "" ""`') + return await ctx.send(f'Désolé, mais il manque des arguments : `{ctx.prefix}sondage "" "" "" ""`') @cog_ext.cog_slash(name="sondage", description = "Fais un sondage.") async def __sondage(self, ctx, question, prop1, prop2, prop3 = None, prop4 = None, prop5 = None, prop6 = None, prop7 = None, prop8 = None, prop9 = None, prop10 = None,