adding the iq function in the slashs commands

This commit is contained in:
Mylloon 2021-05-28 21:22:43 +02:00
parent ed2d7b9a2e
commit 4226c1758e

View file

@ -14,31 +14,42 @@ class Fun(commands.Cog):
self.client = client self.client = client
@commands.command(name='iq') @commands.command(name='iq')
async def _iq(self, ctx, *, user = '0'): async def _iq(self, ctx, *user):
"""Calcule ton IQ.\n ➡ Syntaxe: {PREFIX}iq [user]""" """Calcule ton QI.\n ➡ Syntaxe: {PREFIX}iq [user]"""
if user == '0': fromSlash = False
if user[-1] == True:
fromSlash = user[-1]
user = user[:-1]
if len(user) == 0:
user = ctx.author user = ctx.author
if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(f"T'as {randint(randint(-100,0),220)} IQ {user.mention} !") return await ctx.send(f"T'as {randint(randint(-100,0),220)} IQ {user.mention} !")
else: else:
user = user[0]
try: try:
user2 = user user2 = user
user2 = user2[2:-1] user2 = user2[2:-1]
user2 = user2.replace("!","") user2 = user2.replace("!","")
user2 = int(user2) user2 = int(user2)
user2 = self.client.get_user(user2) user2 = self.client.get_user(user2)
KassouBot = self.client.get_user(740140888373854269) if user2.id == self.client.user.id:
if user2.id == KassouBot.id: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(f"Bah... pas ouf... j'ai juste 100000 IQ :/") return await ctx.send(f"Bah... pas ouf... j'ai juste 100000 de QI :/")
else: else:
if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
message = await ctx.send("...") message = await ctx.send("...")
return await message.edit(content = f"{user2.mention} a {randint(randint(-100,0),220)} IQ !") return await message.edit(content = f"{user2.mention} a {randint(randint(-100,0),220)} de QI !")
except: except:
if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
message = await ctx.send("...") message = await ctx.send("...")
return await message.edit(content = f"{user} a {randint(randint(-100,0),220)} IQ !") return await message.edit(content = f"{user} a {randint(randint(-100,0),220)} de QI !")
@cog_ext.cog_slash(name="iq", description = "Calcule ton QI.")
async def __iq(self, ctx, user = ()):
await self._iq(ctx, user, True)
@commands.command(name='love') @commands.command(name='love')
async def _love(self, ctx, *users: discord.Member): async def _love(self, ctx, *users: discord.Member):
@ -112,7 +123,7 @@ class Fun(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(f"{'Pile' if randint(0,1) == 1 else 'Face'} !") return await ctx.send(f"{'Pile' if randint(0,1) == 1 else 'Face'} !")
@cog_ext.cog_slash(name="pileouface", description = "Pile ou face.") @cog_ext.cog_slash(name="pileouface", description = "Pile ou face.")
async def __pileouface(self, ctx: SlashContext): async def __pileouface(self, ctx):
await self._pileouface(ctx, True) await self._pileouface(ctx, True)
@commands.command(name='mock') @commands.command(name='mock')