ajout fonction pour passer récupérer l'id d'une mention + meilleur agencement du code
This commit is contained in:
parent
9b77418728
commit
90e719241b
5 changed files with 20 additions and 19 deletions
|
@ -100,7 +100,6 @@ class ConfrerieDuKassoulait(commands.Cog):
|
|||
# ne fonctionne pas quand un message a été supprimé avant que le bot ai démarré
|
||||
# info sur la personne qui a supprimé ne fonctionne pas si il a supprimé un message auparavant (les logs se rajoute a un log deja existant)
|
||||
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
if message.author.id == 786897204816117771 and message.author.name == "GitHub" and message.author.bot: # Autopublish
|
||||
|
|
|
@ -3,7 +3,7 @@ from re import findall
|
|||
from discord.ext import commands
|
||||
from random import randint, choice
|
||||
from discord_slash import cog_ext
|
||||
from utils.core import retirerDoublons
|
||||
from utils.core import retirerDoublons, mentionToUser
|
||||
from utils.time import intToDatetime
|
||||
|
||||
def setup(client):
|
||||
|
@ -26,29 +26,25 @@ class Fun(commands.Cog):
|
|||
user = ctx.author
|
||||
if fromSlash != True:
|
||||
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)} de QI {user.mention} !")
|
||||
else:
|
||||
user = user[0]
|
||||
try:
|
||||
user2 = user
|
||||
user2 = user2[2:-1]
|
||||
user2 = user2.replace("!","")
|
||||
user2 = int(user2)
|
||||
user2 = self.client.get_user(user2)
|
||||
user2 = self.client.get_user(mentionToUser(user))
|
||||
if user2.id == self.client.user.id:
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
return await ctx.send(f"Bah... pas ouf... j'ai juste 100000 de QI :/")
|
||||
return await ctx.send(f"Bah euh... j'ai que (au moins) 100 000 de QI :/")
|
||||
else:
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
message = await ctx.send("...")
|
||||
return await message.edit(content = f"{user2.mention} a {randint(randint(-100,0),220)} de QI !")
|
||||
return await message.edit(content = f"{user2.mention} a {randint(randint(-100,0),220)} de QI !")
|
||||
except:
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
message = await ctx.send("...")
|
||||
return await message.edit(content = f"{user} a {randint(randint(-100,0),220)} de QI !")
|
||||
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 = None):
|
||||
if user == None:
|
||||
|
|
|
@ -61,7 +61,7 @@ class Games(commands.Cog):
|
|||
return await ctx.send("Tu es déjà en partie.")
|
||||
guess = 5
|
||||
self.guessing_game[str(ctx.author.id)] = guess
|
||||
number = randint(1,100)
|
||||
number = randint(1, 100)
|
||||
message = f"Choisis un nombre entre 1 et 100 {ctx.author.mention}."
|
||||
await ctx.send(message)
|
||||
while self.guessing_game[str(ctx.author.id)] != 0:
|
||||
|
@ -111,7 +111,7 @@ class Games(commands.Cog):
|
|||
fromSlash = False
|
||||
if fromSlash != True:
|
||||
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.")
|
||||
async def __pileouface(self, ctx):
|
||||
await self._pileouface(ctx, True)
|
||||
|
|
|
@ -5,7 +5,7 @@ from discord.ext import commands, tasks
|
|||
from random import randint, shuffle
|
||||
from discord_slash import cog_ext
|
||||
from utils.reminder import Reminder
|
||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick
|
||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick, mentionToUser
|
||||
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom
|
||||
|
||||
def setup(client):
|
||||
|
@ -32,7 +32,11 @@ class Utils(commands.Cog):
|
|||
arg = None
|
||||
|
||||
if arg == 'help':
|
||||
return await ctx.send(embed = discord.Embed(color = discord.Colour.random(), description = ":hourglass: correspond au temps entre deux battements de cœurs\n\n:heartbeat: correspond au temps que met le client a réagir au messages (0 est normal lors de l'utilisation d'une commande slash)\n\n:stopwatch: correspond au temps que met le client a calculer le ping"))
|
||||
return await ctx.send(embed = discord.Embed(color = discord.Colour.random(), description =
|
||||
":hourglass: correspond au temps entre deux battements de cœurs\n\n \
|
||||
:heartbeat: correspond au temps que met le client a réagir au messages (0 est normal lors de l'utilisation d'une commande slash)\n\n \
|
||||
:stopwatch: correspond au temps que met le client a calculer le ping"
|
||||
))
|
||||
else:
|
||||
now = int(round(nowCustom() * 1000))
|
||||
if fromSlash != True:
|
||||
|
@ -53,7 +57,6 @@ class Utils(commands.Cog):
|
|||
else:
|
||||
return await self._ping(ctx, arg, True)
|
||||
|
||||
|
||||
@commands.command(name='avatar')
|
||||
async def _avatar(self, ctx, *user):
|
||||
"""Affiche ton avatar ou celui que tu mentionnes.\n ➡ Syntaxe: {PREFIX}avatar [user]"""
|
||||
|
@ -70,7 +73,7 @@ class Utils(commands.Cog):
|
|||
if user == None:
|
||||
user = ctx.author
|
||||
else:
|
||||
user = self.client.get_user(int(user[2:-1].replace("!","")))
|
||||
user = self.client.get_user(mentionToUser(user))
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
embed = discord.Embed(description = f"[lien vers la photo de profil]({user.avatar_url}) de {user.mention}", color = discord.Colour.random())
|
||||
|
@ -372,7 +375,7 @@ class Utils(commands.Cog):
|
|||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
return await ctx.send(embed = embed)
|
||||
return await ctx.send(f"Tu mentionnes trop d'utilisateurs : `{ctx.prefix}whois [@Membre]`")
|
||||
return await ctx.send(f"Tu mentionnes trop d'utilisateurs : `{ctx.prefix}whois [@membre]`")
|
||||
@cog_ext.cog_slash(name="whois", description = "Affiche les infos sur l'utilisateur.")
|
||||
async def __whois(self, ctx, user: discord.Member = None):
|
||||
ctx.prefix = "/" # pas sûr que ce soit utile
|
||||
|
@ -600,7 +603,7 @@ class Utils(commands.Cog):
|
|||
utilisateur = utilisateur[:-1]
|
||||
if len(utilisateur) > 0:
|
||||
try:
|
||||
utilisateur = int(getMentionInString(utilisateur[0])[0][2:][:-1].replace("!", ""))
|
||||
utilisateur = mentionToUser(getMentionInString(utilisateur[0])[0])
|
||||
except:
|
||||
return await ctx.send("L'utilisateur renseigné n'a pas été trouvé.")
|
||||
else:
|
||||
|
|
|
@ -107,3 +107,6 @@ def ligneFormatage(ligne):
|
|||
for balises in liste_balise:
|
||||
ligne = ligne.replace(balises[0], balises[1])
|
||||
return ligne
|
||||
|
||||
def mentionToUser(mention: str):
|
||||
return int(mention[2:-1].replace("!",""))
|
||||
|
|
Reference in a new issue