handle error in whois command (no member found)

This commit is contained in:
Mylloon 2021-08-23 12:47:06 +02:00
parent df858f407d
commit a7c42594b5

View file

@ -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 "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`')
return await ctx.send(f'Désolé, mais il manque des arguments : `{ctx.prefix}sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`')
@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,