adding mock slash command

This commit is contained in:
Mylloon 2021-08-18 23:04:45 +02:00
parent e28587fee9
commit 57449b3c06

View file

@ -134,13 +134,21 @@ class Fun(commands.Cog):
await self._8ball(ctx, True)
@commands.command(name='mock')
async def _mock(self, ctx):
async def _mock(self, ctx, fromSlash = None):
"""Se moque du message précédent. - Slash command not available"""
if fromSlash != True:
fromSlash = False
first = 0
suite_auteur = None
temps_limite = intToDatetime((await ctx.message.channel.history(limit = 2).flatten())[1].created_at.timestamp() - 300) # on retire 5 minutes (5 x 60 secondes)
if fromSlash == True:
channel = ctx.channel_text
else:
channel = ctx.message.channel
temps_limite = intToDatetime((await channel.history(limit = 2).flatten())[1].created_at.timestamp() - 300) # on retire 5 minutes (5 x 60 secondes)
final_message = ""
async for message in ctx.message.channel.history(limit = 20, after = temps_limite, oldest_first = False):
async for message in channel.history(limit = 20, after = temps_limite, oldest_first = False):
if first == 0:
first = 1
continue
@ -168,11 +176,19 @@ class Fun(commands.Cog):
if randint(0,1) == 1:
message[i] = message[i].upper()
await ctx.message.delete()
if len(message) > 0:
return await ctx.send("".join(message).replace("\\N", "\n").replace("\\n", "\n"))
if fromSlash == True:
await ctx.send("Envoyé !", hidden = True)
else:
await ctx.message.delete()
return await channel.send("".join(message).replace("\\N", "\n").replace("\\n", "\n"))
else:
return await ctx.send("Le message ne contient aucun texte.", delete_after = 5)
return await mySendHidden(ctx, fromSlash, "Le message ne contient aucun texte.", delete_after = 5)
@cog_ext.cog_slash(name="mock", description = "Se moque du message précédent.")
async def __mock(self, ctx):
"""Slash command"""
ctx.channel_text = self.client.get_channel(ctx.channel_id)
return await self._mock(ctx, True)
@commands.command(name='random', aliases=['randint'])
async def _random(self, ctx, *n):