use addReaction method everywhere

This commit is contained in:
Mylloon 2021-08-17 11:53:38 +02:00
parent feed2b0c27
commit 35127a7a18
8 changed files with 68 additions and 67 deletions

View file

@ -3,7 +3,7 @@ from re import findall
from discord.ext import commands from discord.ext import commands
from random import randint, choice from random import randint, choice
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import retirerDoublons, mentionToUser, isSlash, mySendHidden from utils.core import retirerDoublons, mentionToUser, isSlash, mySendHidden, addReaction
from utils.time import intToDatetime from utils.time import intToDatetime
def setup(client): def setup(client):
@ -23,7 +23,7 @@ class Fun(commands.Cog):
if len(user) == 0: if len(user) == 0:
user = ctx.author user = ctx.author
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(f"T'as {randint(randint(-100, 0), 220)} de QI {user.mention} !") return await ctx.send(f"T'as {randint(randint(-100, 0), 220)} de QI {user.mention} !")
else: else:
user = user[0] user = user[0]
@ -31,16 +31,16 @@ class Fun(commands.Cog):
user2 = self.client.get_user(mentionToUser(user)) user2 = self.client.get_user(mentionToUser(user))
if user2.id == self.client.user.id: if user2.id == self.client.user.id:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(f"Bah euh... j'ai que (au moins) 100 000 de QI :/") return await ctx.send(f"Bah euh... j'ai que (au moins) 100 000 de QI :/")
else: else:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
message = await ctx.send("...") 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: except:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
message = await ctx.send("...") 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.") @cog_ext.cog_slash(name="iq", description = "Calcule ton QI.")
@ -66,7 +66,7 @@ class Fun(commands.Cog):
UneDemande = True UneDemande = True
if users[0] == users[1]: if users[0] == users[1]:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await mySendHidden(ctx, fromSlash, "Je suis sûr que cette personne s'aime ! :angry:") return await mySendHidden(ctx, fromSlash, "Je suis sûr que cette personne s'aime ! :angry:")
if users[0].nick: if users[0].nick:
user1 = list(users[0].nick) user1 = list(users[0].nick)
@ -90,14 +90,14 @@ class Fun(commands.Cog):
coef_amour = 100 coef_amour = 100
if UneDemande == True: if UneDemande == True:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(f"Tu as {coef_amour}% de chance de te mettre en couple avec {''.join(user1)}") return await ctx.send(f"Tu as {coef_amour}% de chance de te mettre en couple avec {''.join(user1)}")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(f"{''.join(user1)} et {''.join(user2)} ont {coef_amour}% de chance de se mettre en couple !") await ctx.send(f"{''.join(user1)} et {''.join(user2)} ont {coef_amour}% de chance de se mettre en couple !")
else: else:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
await ctx.send(f"Erreur! Syntaxe : `{ctx.prefix}love <User1> [User2]`\n") await ctx.send(f"Erreur! Syntaxe : `{ctx.prefix}love <User1> [User2]`\n")
@_love.error @_love.error
async def _love_error(self, ctx, error): async def _love_error(self, ctx, error):
@ -121,7 +121,7 @@ class Fun(commands.Cog):
"je ferais mieux de pas te le dire maintenant...","je ne peux pas le prédire actuellement :/","concentre-toi et redemande.","n'y comptes pas trop.","ma réponse est non.", "je ferais mieux de pas te le dire maintenant...","je ne peux pas le prédire actuellement :/","concentre-toi et redemande.","n'y comptes pas trop.","ma réponse est non.",
"mes sources disent que non.", "les perspectives ne sont pas si bonnes...","c'est très douteux."] "mes sources disent que non.", "les perspectives ne sont pas si bonnes...","c'est très douteux."]
if fromSlash != True: if fromSlash != True:
if fromSlash != True: await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(f"{ctx.author.mention}, {choice(reponses)}") return await ctx.send(f"{ctx.author.mention}, {choice(reponses)}")
@_8ball.error @_8ball.error
async def _8ball_error(self, ctx, error): async def _8ball_error(self, ctx, error):
@ -192,7 +192,7 @@ class Fun(commands.Cog):
x, n = n, x x, n = n, x
resultat = randint(x, n) resultat = randint(x, n)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(embed = discord.Embed().set_author(name = f"Tu as tiré le chiffre {resultat} !")) return await ctx.send(embed = discord.Embed().set_author(name = f"Tu as tiré le chiffre {resultat} !"))
@cog_ext.cog_slash(name="random", description = "Tire au hasard un chiffre entre 1 et n (par défaut n=10)") @cog_ext.cog_slash(name="random", description = "Tire au hasard un chiffre entre 1 et n (par défaut n=10)")
async def __random(self, ctx, n: int = None): async def __random(self, ctx, n: int = None):

View file

@ -3,7 +3,7 @@ import asyncio
from discord.ext import commands from discord.ext import commands
from random import randint, choice from random import randint, choice
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden, addReaction
def setup(client): def setup(client):
"""Adding Cog to bot""" """Adding Cog to bot"""
@ -46,7 +46,7 @@ class Games(commands.Cog):
embed = discord.Embed(title = f"{choix_jeu[choix][-1:]}VS {choix_jeu[ordi][-1:]}", description = description) embed = discord.Embed(title = f"{choix_jeu[choix][-1:]}VS {choix_jeu[ordi][-1:]}", description = description)
embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar_url) embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar_url)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(embed = embed) return await ctx.send(embed = embed)
@_chifumi.error @_chifumi.error
async def _chifumi_error(self, ctx, _): async def _chifumi_error(self, ctx, _):
@ -113,7 +113,7 @@ class Games(commands.Cog):
if fromSlash != True: if fromSlash != True:
fromSlash = False fromSlash = False
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
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): async def __pileouface(self, ctx):

View file

@ -1,7 +1,7 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden, addReaction
def setup(client): def setup(client):
"""Adding Cog to bot""" """Adding Cog to bot"""
@ -20,8 +20,8 @@ class Help(commands.Cog):
erreur = False erreur = False
if not cog: # Liste des Cog if not cog: # Liste des Cog
halp = discord.Embed(title = 'Liste des catégories et commandes sans catégorie', halp = discord.Embed(title = "Liste des catégories et commandes sans catégorie",
description = f'Utilisez `{ctx.prefix}help [catégorie]` pour en savoir plus sur elles et leur commande.', description = f"Utilisez `{ctx.prefix}help [catégorie]` pour en savoir plus sur elles et leur commande.",
color = discord.Colour.random()) color = discord.Colour.random())
for name_cog in self.client.cogs: for name_cog in self.client.cogs:
liste_cmds = "" liste_cmds = ""
@ -31,21 +31,21 @@ class Help(commands.Cog):
liste_cmds += f", `{ctx.prefix}{cmds.name}`" liste_cmds += f", `{ctx.prefix}{cmds.name}`"
nb_cmds += 1 nb_cmds += 1
if name_cog != "Help" and nb_cmds > 0: if name_cog != "Help" and nb_cmds > 0:
halp.add_field(name = f'**{name_cog} ({nb_cmds}) — {self.client.cogs[name_cog].__doc__}**', value = liste_cmds[2:], inline = False) halp.add_field(name = f"**{name_cog} ({nb_cmds}) — {self.client.cogs[name_cog].__doc__}**", value = liste_cmds[2:], inline = False)
cmds_desc = '' cmds_desc = ''
for y in self.client.walk_commands(): for y in self.client.walk_commands():
if not y.cog_name and not y.hidden: if not y.cog_name and not y.hidden:
cmds_desc += (f'{ctx.prefix}{y.name} - {y.help}\n ') cmds_desc += (f"{ctx.prefix}{y.name} - {y.help}\n")
if len(cmds_desc) > 1: if len(cmds_desc) > 1:
halp.add_field(name = 'Commandes sans catégorie', value = cmds_desc[0:len(cmds_desc)-1], inline = False) halp.add_field(name = "Commandes sans catégorie", value = cmds_desc[0:len(cmds_desc)-1], inline = False)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = halp) await ctx.send(embed = halp)
else: # Avertissement si il y a trop d'arguments dans la variable cog else: # Avertissement si il y a trop d'arguments dans la variable cog
if len(cog) > 1: if len(cog) > 1:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
halp = discord.Embed(title = 'Erreur !', description = "Tu as renseigné trop d'arguments !", color = 0xC41B1B) halp = discord.Embed(title = "Erreur !", description = "Tu as renseigné trop d'arguments !", color = 0xC41B1B)
await ctx.send(embed = halp) await ctx.send(embed = halp)
else: # Liste des commandes avec cogs. else: # Liste des commandes avec cogs.
cog = [item.capitalize() for item in cog] cog = [item.capitalize() for item in cog]
@ -53,7 +53,7 @@ class Help(commands.Cog):
for x in self.client.cogs: for x in self.client.cogs:
for y in cog: for y in cog:
if x == y: if x == y:
halp = discord.Embed(title = f'{cog[0]} - Liste des commandes', description = self.client.cogs[cog[0]].__doc__, color = discord.Colour.random()) halp = discord.Embed(title = f"{cog[0]} - Liste des commandes", description = self.client.cogs[cog[0]].__doc__, color = discord.Colour.random())
for c in self.client.get_cog(y).get_commands(): for c in self.client.get_cog(y).get_commands():
if not c.hidden: if not c.hidden:
cmds_help = str(c.help).replace("{PREFIX}", ctx.prefix).split("\n") cmds_help = str(c.help).replace("{PREFIX}", ctx.prefix).split("\n")
@ -63,12 +63,12 @@ class Help(commands.Cog):
found = True found = True
if not found: # Rappel si le cog n'existe pas. if not found: # Rappel si le cog n'existe pas.
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
halp = discord.Embed(title = 'Erreur !', description = f"Qu'est ce que {cog[0]} ?", color = 0xC41B1B) halp = discord.Embed(title = "Erreur !", description = f"Qu'est ce que {cog[0]} ?", color = 0xC41B1B)
erreur = True erreur = True
else: else:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await mySendHidden(ctx, erreur, embed = halp) await mySendHidden(ctx, erreur, embed = halp)
@cog_ext.cog_slash(name="help", description = "Affiche toutes les commandes du bot.") @cog_ext.cog_slash(name="help", description = "Affiche toutes les commandes du bot.")
async def __help(self, ctx, cog = None): async def __help(self, ctx, cog = None):
@ -79,14 +79,14 @@ class Help(commands.Cog):
else: else:
return await self._help(ctx, cog, True) return await self._help(ctx, cog, True)
@commands.command(name='invite') @commands.command(name="invite")
async def _invite(self, ctx, fromSlash = None): async def _invite(self, ctx, fromSlash = None):
"""Invite ce bot sur ton serveur !""" """Invite ce bot sur ton serveur !"""
if fromSlash != True: if fromSlash != True:
fromSlash = False fromSlash = False
embed = discord.Embed(description = f"[Lien vers l'invitation Discord](https://discord.com/api/oauth2/authorize?client_id={self.client.user.id}&permissions=8&scope=bot%20applications.commands)").set_author(name="Invite moi !") embed = discord.Embed(description = f"[Lien vers l'invitation Discord](https://discord.com/api/oauth2/authorize?client_id={self.client.user.id}&permissions=8&scope=bot%20applications.commands)").set_author(name="Invite moi !")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(embed = embed) return await ctx.send(embed = embed)
@cog_ext.cog_slash(name="invite", description = "Invite ce bot sur ton serveur !") @cog_ext.cog_slash(name="invite", description = "Invite ce bot sur ton serveur !")
async def __invite(self, ctx): async def __invite(self, ctx):

View file

@ -4,7 +4,7 @@ from discord.ext import commands
from random import choice from random import choice
from asyncpraw import Reddit from asyncpraw import Reddit
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import randomImage, isSlash, mySendHidden, load from utils.core import randomImage, isSlash, mySendHidden, load, addReaction
def setup(client): def setup(client):
"""Adding Cog to bot""" """Adding Cog to bot"""
@ -57,7 +57,7 @@ class Internet(commands.Cog):
else: else:
message = await ctx.send(f"`{subredditchoix.capitalize()} pour {ctx.author.name}`\n{submission.url}") message = await ctx.send(f"`{subredditchoix.capitalize()} pour {ctx.author.name}`\n{submission.url}")
if fromSlash != True and fromSlash != None: if fromSlash != True and fromSlash != None:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
if fromSlash != None: if fromSlash != None:
for emoji in ['🔺', '🔻']: for emoji in ['🔺', '🔻']:
await message.add_reaction(emoji) await message.add_reaction(emoji)
@ -65,7 +65,7 @@ class Internet(commands.Cog):
except Exception as error: except Exception as error:
print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}") print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
return await mySendHidden(ctx, fromSlash, f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})") return await mySendHidden(ctx, fromSlash, f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})")
@cog_ext.cog_slash(name="meme", description = "Envoie un meme de reddit.") @cog_ext.cog_slash(name="meme", description = "Envoie un meme de reddit.")
async def __memes(self, ctx, subreddit = None): async def __memes(self, ctx, subreddit = None):
@ -91,7 +91,7 @@ class Internet(commands.Cog):
embed.set_image(url = cat[0]['file']) embed.set_image(url = cat[0]['file'])
embed.set_footer(text = f"random.cat a pris {cat[1]} ms.") embed.set_footer(text = f"random.cat a pris {cat[1]} ms.")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
message = await ctx.send(embed=embed) message = await ctx.send(embed=embed)
return await message.add_reaction('❤️') return await message.add_reaction('❤️')
@cog_ext.cog_slash(name="cat", description = "Te montre un magnifique chat.") @cog_ext.cog_slash(name="cat", description = "Te montre un magnifique chat.")
@ -114,7 +114,7 @@ class Internet(commands.Cog):
embed.set_image(url = dog[0]['message']) embed.set_image(url = dog[0]['message'])
embed.set_footer(text = f"dog.ceo a pris {dog[1]} ms.") embed.set_footer(text = f"dog.ceo a pris {dog[1]} ms.")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
message = await ctx.send(embed=embed) message = await ctx.send(embed=embed)
return await message.add_reaction('❤️') return await message.add_reaction('❤️')
@cog_ext.cog_slash(name="dog", description = "Te montre un magnifique chien.") @cog_ext.cog_slash(name="dog", description = "Te montre un magnifique chien.")
@ -129,13 +129,13 @@ class Internet(commands.Cog):
fromSlash = False fromSlash = False
if ctx.channel.is_nsfw(): if ctx.channel.is_nsfw():
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
else: else:
ctx.prefix = "/" ctx.prefix = "/"
return await self._memes(ctx, "nsfw", None) return await self._memes(ctx, "nsfw", None)
else: else:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
await mySendHidden(ctx, fromSlash, f"Désolé mais je n'envois ce genre de message seulement dans les salons NSFW !") await mySendHidden(ctx, fromSlash, f"Désolé mais je n'envois ce genre de message seulement dans les salons NSFW !")
@cog_ext.cog_slash(name="sexe", description = "Envois une image coquine. (NSFW)") @cog_ext.cog_slash(name="sexe", description = "Envois une image coquine. (NSFW)")
async def __sexe(self, ctx): async def __sexe(self, ctx):
@ -190,7 +190,7 @@ class Internet(commands.Cog):
embed.set_footer(text = f"News de {choix_site.capitalize()}") embed.set_footer(text = f"News de {choix_site.capitalize()}")
await ctx.send(embed = embed) await ctx.send(embed = embed)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="news", description = "Info random dans le domaine de l'informatique, met commme arg liste pour la liste des sources dispo.") @cog_ext.cog_slash(name="news", description = "Info random dans le domaine de l'informatique, met commme arg liste pour la liste des sources dispo.")
async def __news(self, ctx, source = None): async def __news(self, ctx, source = None):
"""Slash command""" """Slash command"""

View file

@ -2,7 +2,8 @@ import discord
from discord.ext import commands, tasks from discord.ext import commands, tasks
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.reminder import Reminder, embedListe, listReaction from utils.reminder import Reminder, embedListe, listReaction
from utils.core import getURLsInString, getMentionInString, isSlash, mySendHidden, mentionToUser, cleanCodeStringWithMentionAndURLs from utils.core import getURLsInString, getMentionInString, isSlash, mySendHidden
from utils.core import addReaction, mentionToUser, cleanCodeStringWithMentionAndURLs
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString
def setup(client): def setup(client):
@ -47,7 +48,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
except: except:
sourceMessage = None # message a été supprimé sourceMessage = None # message a été supprimé
if sourceMessage != None: if sourceMessage != None:
await sourceMessage.add_reaction(emoji = '') # ajout réaction await addReaction(sourceMessage.message, 0) # ajout réaction
finalEmbed.set_footer(text=f"Message d'il y a {timedeltaToString(int(nowUTC()) - expired[3])}") finalEmbed.set_footer(text=f"Message d'il y a {timedeltaToString(int(nowUTC()) - expired[3])}")
links = "" links = ""
findedURLs = getURLsInString(reminder) findedURLs = getURLsInString(reminder)
@ -101,7 +102,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
seconds = stringTempsVersSecondes(time) seconds = stringTempsVersSecondes(time)
if type(seconds) != int: if type(seconds) != int:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 1)
return await mySendHidden(ctx, fromSlash, seconds) return await mySendHidden(ctx, fromSlash, seconds)
if seconds == 0: if seconds == 0:
embed.add_field(name="Informations", value= embed.add_field(name="Informations", value=
@ -119,7 +120,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
messageID = ctx.message.id messageID = ctx.message.id
reminderID = Reminder().ajoutReminder(messageID, ctx.channel.id, extrarg, reminder, now, now + seconds, ctx.author.id, guildID) reminderID = Reminder().ajoutReminder(messageID, ctx.channel.id, extrarg, reminder, now, now + seconds, ctx.author.id, guildID)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await mySendHidden(ctx, fromSlash, f"Reminder **`#{reminderID[0][0]}`** enrengistré ! Notification {destination} dans {timedeltaToString(seconds)}{'' if seconds >= 3600 else ' (avec 1m de retard maximum)'}.") return await mySendHidden(ctx, fromSlash, f"Reminder **`#{reminderID[0][0]}`** enrengistré ! Notification {destination} dans {timedeltaToString(seconds)}{'' if seconds >= 3600 else ' (avec 1m de retard maximum)'}.")
await mySendHidden(ctx, fromSlash, embed = embed) await mySendHidden(ctx, fromSlash, embed = embed)
@_reminder.error @_reminder.error
@ -155,7 +156,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
return await mySendHidden(ctx, fromSlash, "Veuillez renseigné un utilisateur ou un numéro de page valide.") return await mySendHidden(ctx, fromSlash, "Veuillez renseigné un utilisateur ou un numéro de page valide.")
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
embed, pageMAX, refresh = await embedListe(utilisateur, ctx.guild.id, page) embed, pageMAX, refresh = await embedListe(utilisateur, ctx.guild.id, page)
message = await ctx.send(embed = embed) message = await ctx.send(embed = embed)
@ -202,11 +203,11 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
if verification: if verification:
Reminder().suppressionReminder(id) Reminder().suppressionReminder(id)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await mySendHidden(ctx, fromSlash, f"Reminder **#{id}** supprimé !") return await mySendHidden(ctx, fromSlash, f"Reminder **#{id}** supprimé !")
else: else:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
return await mySendHidden(ctx, fromSlash, "Rappel non trouvé, pas sur le bon serveur ou qui ne vous appartiens pas.") return await mySendHidden(ctx, fromSlash, "Rappel non trouvé, pas sur le bon serveur ou qui ne vous appartiens pas.")
@cog_ext.cog_slash(name="reminderdelete", description = "Suppprime un rappel.") @cog_ext.cog_slash(name="reminderdelete", description = "Suppprime un rappel.")
async def __reminderdelete(self, ctx, id): async def __reminderdelete(self, ctx, id):

View file

@ -1,7 +1,7 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden, addReaction
def setup(client): def setup(client):
"""Adding Cog to bot""" """Adding Cog to bot"""
@ -21,7 +21,7 @@ class School(commands.Cog):
voice_channels = [] voice_channels = []
voice_channels.extend(ctx.guild.voice_channels) voice_channels.extend(ctx.guild.voice_channels)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = "") await addReaction(ctx.message, 0)
limite_voice_channels = 7 limite_voice_channels = 7
if len(voice_channels) > limite_voice_channels and not voice_channel: if len(voice_channels) > limite_voice_channels and not voice_channel:
return await mySendHidden(ctx, fromSlash, f"""Désolé mais il y a plus de {limite_voice_channels} salons vocaux sur ce serveur, utilisez plutôt `{ctx.prefix}appel {{ID salon vocal}}`. return await mySendHidden(ctx, fromSlash, f"""Désolé mais il y a plus de {limite_voice_channels} salons vocaux sur ce serveur, utilisez plutôt `{ctx.prefix}appel {{ID salon vocal}}`.
@ -76,5 +76,5 @@ class School(commands.Cog):
if fromSlash != True: if fromSlash != True:
fromSlash = False fromSlash = False
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await mySendHidden(ctx, fromSlash, "Explication sur comment récuperer l'ID d'un utilisateur/salon : https://cdn.discordapp.com/attachments/640312926892195842/780802253258358834/GetID.mp4") return await mySendHidden(ctx, fromSlash, "Explication sur comment récuperer l'ID d'un utilisateur/salon : https://cdn.discordapp.com/attachments/640312926892195842/780802253258358834/GetID.mp4")

View file

@ -5,7 +5,7 @@ from re import findall
from sys import version as pyVersion from sys import version as pyVersion
from discord_slash import cog_ext from discord_slash import cog_ext
from utils.core import map_list_among_us, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick, getLavalinkVersion from utils.core import map_list_among_us, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick, getLavalinkVersion
from utils.core import mySendHidden, mentionToUser, getChangelogs, getActualVersion, isSlash, load, devOrStableChannel from utils.core import mySendHidden, mentionToUser, getChangelogs, getActualVersion, isSlash, load, devOrStableChannel, addReaction
from utils.time import nowUTC, intToDatetime, timestampScreen, getAge, ageLayout, nowCustom from utils.time import nowUTC, intToDatetime, timestampScreen, getAge, ageLayout, nowCustom
def setup(client): def setup(client):
@ -40,7 +40,7 @@ class Utils(commands.Cog):
ping2 = int(round(nowCustom() * 1000)) - now ping2 = int(round(nowCustom() * 1000)) - now
await message.edit(embed = discord.Embed(color = discord.Colour.random(), description = f':hourglass: {round(self.client.latency * 1000)} ms\n\n:heartbeat: {ping} ms\n\n:stopwatch: {ping2} ms')) await message.edit(embed = discord.Embed(color = discord.Colour.random(), description = f':hourglass: {round(self.client.latency * 1000)} ms\n\n:heartbeat: {ping} ms\n\n:stopwatch: {ping2} ms'))
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="ping", description = "Affiche mon ping, mettre 'help' en argument pour connaître à quoi correspond les données.") @cog_ext.cog_slash(name="ping", description = "Affiche mon ping, mettre 'help' en argument pour connaître à quoi correspond les données.")
async def __ping(self, ctx, arg = None): async def __ping(self, ctx, arg = None):
"""Slash command""" """Slash command"""
@ -60,7 +60,7 @@ class Utils(commands.Cog):
else: else:
user = self.client.get_user(mentionToUser(user)) user = self.client.get_user(mentionToUser(user))
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
embed = discord.Embed(description = f"[lien vers la photo de profil]({user.avatar_url}) de {user.mention}", color = discord.Colour.random()) embed = discord.Embed(description = f"[lien vers la photo de profil]({user.avatar_url}) de {user.mention}", color = discord.Colour.random())
embed.set_author(name = f"Photo de profil de {user.name}") embed.set_author(name = f"Photo de profil de {user.name}")
embed.set_image(url = user.avatar_url) embed.set_image(url = user.avatar_url)
@ -114,7 +114,7 @@ class Utils(commands.Cog):
embed.add_field(name = 'Calcul :', value = equation, inline = False) embed.add_field(name = 'Calcul :', value = equation, inline = False)
embed.add_field(name = 'Réponse :', value = answer.replace('False', 'Faux').replace('True', 'Vrai'), inline = False) embed.add_field(name = 'Réponse :', value = answer.replace('False', 'Faux').replace('True', 'Vrai'), inline = False)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = embed) await ctx.send(embed = embed)
@_calc.error @_calc.error
async def _calc_error(self, ctx, _): async def _calc_error(self, ctx, _):
@ -173,7 +173,7 @@ class Utils(commands.Cog):
syntaxe += ">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n" syntaxe += ">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n"
try: try:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
except: except:
pass pass
await mySendHidden(ctx, fromSlash, syntaxe) await mySendHidden(ctx, fromSlash, syntaxe)
@ -193,11 +193,11 @@ class Utils(commands.Cog):
if len(text) <= 5: if len(text) <= 5:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
return await mySendHidden(ctx, fromSlash, "Ta note doit au moins faire 5 caractères.") return await mySendHidden(ctx, fromSlash, "Ta note doit au moins faire 5 caractères.")
elif len(text) >= 2048: elif len(text) >= 2048:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
return await ctx.send(ctx, fromSlash, "Ta note doit faire moins de 2048 caractères.") return await ctx.send(ctx, fromSlash, "Ta note doit faire moins de 2048 caractères.")
else: else:
if fromSlash != True: if fromSlash != True:
@ -272,7 +272,7 @@ class Utils(commands.Cog):
embed.set_footer(text = f"Basé sur discord.py {discord.__version__}{lavalink}{python}") embed.set_footer(text = f"Basé sur discord.py {discord.__version__}{lavalink}{python}")
try: try:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
except: except:
pass pass
await ctx.send(embed = embed) await ctx.send(embed = embed)
@ -296,28 +296,28 @@ class Utils(commands.Cog):
embed = discord.Embed(title = f"Map Mira HQ d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed = discord.Embed(title = f"Map Mira HQ d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})")
embed.set_image(url = image) embed.set_image(url = image)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = embed) await ctx.send(embed = embed)
elif map.lower() in map_list_among_us("polus"): elif map.lower() in map_list_among_us("polus"):
image = "https://i.imgur.com/mhFmcw3.jpg" image = "https://i.imgur.com/mhFmcw3.jpg"
embed = discord.Embed(title = f"Map Polus d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed = discord.Embed(title = f"Map Polus d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})")
embed.set_image(url = image) embed.set_image(url = image)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = embed) await ctx.send(embed = embed)
elif map.lower() in map_list_among_us("skeld"): elif map.lower() in map_list_among_us("skeld"):
image = "https://i.imgur.com/OSXI4Zv.jpg" image = "https://i.imgur.com/OSXI4Zv.jpg"
embed = discord.Embed(title = f"Map The Skeld d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed = discord.Embed(title = f"Map The Skeld d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})")
embed.set_image(url = image) embed.set_image(url = image)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = embed) await ctx.send(embed = embed)
elif map.lower() in map_list_among_us("airship"): elif map.lower() in map_list_among_us("airship"):
image = "https://i.imgur.com/cm8Wogw.png" image = "https://i.imgur.com/cm8Wogw.png"
embed = discord.Embed(title = f"Map Airship d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed = discord.Embed(title = f"Map Airship d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})")
embed.set_image(url = image) embed.set_image(url = image)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
await ctx.send(embed = embed) await ctx.send(embed = embed)
else: else:
await mySendHidden(ctx, fromSlash, f"`{ctx.prefix}amongus <mira/polus/skeld/airship>`") await mySendHidden(ctx, fromSlash, f"`{ctx.prefix}amongus <mira/polus/skeld/airship>`")
@ -333,7 +333,7 @@ class Utils(commands.Cog):
else: else:
await ctx.invoke(self.client.get_command("amongus")) await ctx.invoke(self.client.get_command("amongus"))
else: else:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 1)
@cog_ext.cog_slash(name="amongus", description = "Affiche la carte voulue d'Among Us. Carte dispo : <mira/polus/skeld/airship>") @cog_ext.cog_slash(name="amongus", description = "Affiche la carte voulue d'Among Us. Carte dispo : <mira/polus/skeld/airship>")
async def __amongus(self, ctx, map): async def __amongus(self, ctx, map):
"""Slash command""" """Slash command"""
@ -365,7 +365,7 @@ class Utils(commands.Cog):
embed.add_field(name = "Est sur le serveur depuis", value = ageLayout(getAge(user[0].joined_at))) embed.add_field(name = "Est sur le serveur depuis", value = ageLayout(getAge(user[0].joined_at)))
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send(embed = embed) 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.") @cog_ext.cog_slash(name="whois", description = "Affiche les infos sur l'utilisateur.")
@ -417,7 +417,7 @@ class Utils(commands.Cog):
for i in range(len(args[1:])): for i in range(len(args[1:])):
await sondage.add_reaction(emoji = emojis_chosen[i]) await sondage.add_reaction(emoji = emojis_chosen[i])
if fromSlash != True: if fromSlash != True:
return await ctx.message.add_reaction(emoji = '') return await addReaction(ctx.message, 0)
else: else:
return await ctx.send(f"Désolé, mais tu as mis trop de possibilités (maximum : 20)") return await ctx.send(f"Désolé, mais tu as mis trop de possibilités (maximum : 20)")
else: else:
@ -480,7 +480,7 @@ class Utils(commands.Cog):
changes = getChangelogs(version.replace(',', '.')) changes = getChangelogs(version.replace(',', '.'))
if changes[0] != 200: if changes[0] != 200:
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 2)
if changes[0] == 404: if changes[0] == 404:
message = "Veuillez renseigner un numéro de version valide et existant. Peut-être que vous utilisez une version de développement." message = "Veuillez renseigner un numéro de version valide et existant. Peut-être que vous utilisez une version de développement."
elif changes[0] == 429: elif changes[0] == 429:
@ -489,7 +489,7 @@ class Utils(commands.Cog):
message = f"Erreur API inconnue ({changes[0]})." message = f"Erreur API inconnue ({changes[0]})."
return await mySendHidden(ctx, fromSlash, message) return await mySendHidden(ctx, fromSlash, message)
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
changements = changes[3].replace("## ", "").replace("# ", "") changements = changes[3].replace("## ", "").replace("# ", "")
if len(changements) > 2048: if len(changements) > 2048:
changements = f"{changements[:1900]}..." changements = f"{changements[:1900]}..."
@ -510,7 +510,7 @@ class Utils(commands.Cog):
if fromSlash != True: if fromSlash != True:
fromSlash = False fromSlash = False
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 0)
return await ctx.send("https://imgr.search.brave.com/5-k6Lgh0OyRI8IVwhiBrNRmlY94utGxSX0k9tvtpqiA/fit/590/150/no/1/aHR0cDovL2kuaW1n/dXIuY29tL3Azd2lz/OVAucG5n") return await ctx.send("https://imgr.search.brave.com/5-k6Lgh0OyRI8IVwhiBrNRmlY94utGxSX0k9tvtpqiA/fit/590/150/no/1/aHR0cDovL2kuaW1n/dXIuY29tL3Azd2lz/OVAucG5n")
@cog_ext.cog_slash(name="minecraft", description = "Affiche le code couleur utilisé dans Minecraft.") @cog_ext.cog_slash(name="minecraft", description = "Affiche le code couleur utilisé dans Minecraft.")
async def __minecraft(self, ctx): async def __minecraft(self, ctx):

View file

@ -5,7 +5,7 @@ from os import listdir, rename, getcwd
from discord_slash import SlashCommand from discord_slash import SlashCommand
from discord.ext import commands from discord.ext import commands
from utils.reminder import Reminder from utils.reminder import Reminder
from utils.core import load from utils.core import load, addReaction
keys = load(["PREFIX", "TOKEN_DISCORD", "DEACTIVATE"]) keys = load(["PREFIX", "TOKEN_DISCORD", "DEACTIVATE"])
customPrefix = keys["PREFIX"] customPrefix = keys["PREFIX"]
@ -54,7 +54,7 @@ async def on_command_error(ctx, error):
if not ctx.invoked_with.startswith(customPrefix): if not ctx.invoked_with.startswith(customPrefix):
print(error) print(error)
if ctx.message: if ctx.message:
await ctx.message.add_reaction(emoji = '') await addReaction(ctx.message, 1)
@client.event @client.event
async def on_message(message): async def on_message(message):