add comments

This commit is contained in:
Mylloon 2021-08-17 11:35:25 +02:00
parent 1da3aac896
commit feed2b0c27
11 changed files with 76 additions and 4 deletions

View file

@ -5,6 +5,7 @@ from utils.core import userOrNick
from utils.time import timestampScreen from utils.time import timestampScreen
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(Citation(client)) client.add_cog(Citation(client))
class Citation(commands.Cog): class Citation(commands.Cog):
@ -14,6 +15,7 @@ class Citation(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_message(self, message): async def on_message(self, message):
"""Triggered a message is received"""
urls = findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content) urls = findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content)
httpsString = "https://" httpsString = "https://"
channelsString = "discord.com/channels/" channelsString = "discord.com/channels/"

View file

@ -7,6 +7,7 @@ from utils.time import nowCustom, intToDatetime, nowUTC, timestampScreen
from cogs.internet import Internet from cogs.internet import Internet
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(ConfrerieDuKassoulait(client)) client.add_cog(ConfrerieDuKassoulait(client))
class ConfrerieDuKassoulait(commands.Cog): class ConfrerieDuKassoulait(commands.Cog):
@ -16,6 +17,7 @@ class ConfrerieDuKassoulait(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_join(self, member): async def on_member_join(self, member):
"""Triggered when a member join a guild"""
if member.guild.id == 441208120644075520: # Confrérie du Kassoulait if member.guild.id == 441208120644075520: # Confrérie du Kassoulait
if member.bot == True: if member.bot == True:
role = discord.utils.get(member.guild.roles, name = "Bot") role = discord.utils.get(member.guild.roles, name = "Bot")
@ -45,12 +47,14 @@ class ConfrerieDuKassoulait(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_remove(self, member): async def on_member_remove(self, member):
"""Triggered when a member leave a guild"""
if member.guild.id == 441208120644075520: # Confrérie du Kassoulait if member.guild.id == 441208120644075520: # Confrérie du Kassoulait
channel = self.client.get_channel(741639570172674120) # salons des arrivées channel = self.client.get_channel(741639570172674120) # salons des arrivées
await channel.send(f"{member.mention} ({member.name}) vient de quitter le serveur.") await channel.send(f"{member.mention} ({member.name}) vient de quitter le serveur.")
@commands.Cog.listener() @commands.Cog.listener()
async def on_message_delete(self, message): async def on_message_delete(self, message):
"""Triggered when a message is deleted"""
try: try:
if message.author.guild.id == 441208120644075520: # Confrérie du Kassoulait if message.author.guild.id == 441208120644075520: # Confrérie du Kassoulait
prefix = await self.client.get_prefix(message) prefix = await self.client.get_prefix(message)
@ -84,6 +88,7 @@ class ConfrerieDuKassoulait(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_message(self, message): async def on_message(self, message):
"""Triggered a message is received"""
if message.author.id == 869726667294248970 and message.author.bot: # Autopublish if message.author.id == 869726667294248970 and message.author.bot: # Autopublish
await message.publish() await message.publish()

View file

@ -7,6 +7,7 @@ from utils.core import retirerDoublons, mentionToUser, isSlash, mySendHidden
from utils.time import intToDatetime from utils.time import intToDatetime
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(Fun(client)) client.add_cog(Fun(client))
class Fun(commands.Cog): class Fun(commands.Cog):
@ -44,6 +45,7 @@ class Fun(commands.Cog):
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.")
async def __iq(self, ctx, user = None): async def __iq(self, ctx, user = None):
"""Slash command"""
if user == None: if user == None:
return await self._iq(ctx, True) return await self._iq(ctx, True)
else: else:
@ -99,9 +101,11 @@ class Fun(commands.Cog):
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):
"""Error command handler"""
await ctx.send(str(error).replace('Member "', "Le membre **").replace('" not found', "** n'as pas été trouvé.")) await ctx.send(str(error).replace('Member "', "Le membre **").replace('" not found', "** n'as pas été trouvé."))
@cog_ext.cog_slash(name="love", description = "Découvre la probabilité que ces deux personnes se mettent en couple.") @cog_ext.cog_slash(name="love", description = "Découvre la probabilité que ces deux personnes se mettent en couple.")
async def __love(self, ctx, user1: discord.Member, user2: discord.Member = None): async def __love(self, ctx, user1: discord.Member, user2: discord.Member = None):
"""Slash command"""
if user2 != None: if user2 != None:
return await self._love(ctx, user1, user2, True) return await self._love(ctx, user1, user2, True)
else: else:
@ -121,10 +125,12 @@ class Fun(commands.Cog):
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):
"""Error command handler"""
if str(error) == "question is a required argument that is missing.": if str(error) == "question is a required argument that is missing.":
await ctx.send(f"Mauvaise syntaxe : `{ctx.prefix}8ball/8b/8balls <question>`.") await ctx.send(f"Mauvaise syntaxe : `{ctx.prefix}8ball/8b/8balls <question>`.")
@cog_ext.cog_slash(name="8ball", description = "Répond à ta question 🔮.") @cog_ext.cog_slash(name="8ball", description = "Répond à ta question 🔮.")
async def __8ball(self, ctx, question): async def __8ball(self, ctx, question):
"""Slash command"""
await self._8ball(ctx, True) await self._8ball(ctx, True)
@commands.command(name='mock') @commands.command(name='mock')
@ -190,6 +196,7 @@ class Fun(commands.Cog):
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):
"""Slash command"""
if n == None: if n == None:
await self._random(ctx, True) await self._random(ctx, True)
else: else:

View file

@ -6,6 +6,7 @@ from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(Games(client)) client.add_cog(Games(client))
class Games(commands.Cog): class Games(commands.Cog):
@ -48,10 +49,12 @@ class Games(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(embed = embed) return await ctx.send(embed = embed)
@_chifumi.error @_chifumi.error
async def _chifumi_error(self, ctx, error): async def _chifumi_error(self, ctx, _):
"""Error command handler"""
await ctx.send(f"Mauvaise syntaxe : `{ctx.prefix}chifumi/shifumi/ppc <pierre/papier/ciseaux>`.") await ctx.send(f"Mauvaise syntaxe : `{ctx.prefix}chifumi/shifumi/ppc <pierre/papier/ciseaux>`.")
@cog_ext.cog_slash(name="chifumi", description = "Un simple Chifumi contre le bot. <pierre/papier/ciseaux>") @cog_ext.cog_slash(name="chifumi", description = "Un simple Chifumi contre le bot. <pierre/papier/ciseaux>")
async def __chifumi(self, ctx, choix): async def __chifumi(self, ctx, choix):
"""Slash command"""
return await self._chifumi(ctx, choix, True) return await self._chifumi(ctx, choix, True)
@commands.command(name='plusoumoins', aliases = ['+ou-', '+-']) @commands.command(name='plusoumoins', aliases = ['+ou-', '+-'])
@ -101,6 +104,7 @@ class Games(commands.Cog):
await ctx.send(f"T'as pas trouvé {ctx.author.mention}... dommage, c'était {number}.") await ctx.send(f"T'as pas trouvé {ctx.author.mention}... dommage, c'était {number}.")
@cog_ext.cog_slash(name="plusoumoins", description = "Un plus ou moins entre 1 et 100.") @cog_ext.cog_slash(name="plusoumoins", description = "Un plus ou moins entre 1 et 100.")
async def __plusoumoins(self, ctx): async def __plusoumoins(self, ctx):
"""Slash command"""
await self._plusoumoins(ctx, True) await self._plusoumoins(ctx, True)
@commands.command(name='pileouface', aliases=['pf']) @commands.command(name='pileouface', aliases=['pf'])
@ -113,4 +117,5 @@ class Games(commands.Cog):
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):
"""Slash command"""
await self._pileouface(ctx, True) await self._pileouface(ctx, True)

View file

@ -4,6 +4,7 @@ from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(Help(client)) client.add_cog(Help(client))
class Help(commands.Cog): class Help(commands.Cog):
@ -71,6 +72,7 @@ class Help(commands.Cog):
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):
"""Slash command"""
ctx.prefix = "/" ctx.prefix = "/"
if cog == None: if cog == None:
return await self._help(ctx, True) return await self._help(ctx, True)
@ -88,4 +90,5 @@ class Help(commands.Cog):
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):
"""Slash command"""
return await self._invite(ctx, True) return await self._invite(ctx, True)

View file

@ -7,6 +7,7 @@ from discord_slash import cog_ext
from utils.core import randomImage, isSlash, mySendHidden, load from utils.core import randomImage, isSlash, mySendHidden, load
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(Internet(client)) client.add_cog(Internet(client))
class Internet(commands.Cog): class Internet(commands.Cog):
@ -68,6 +69,7 @@ class Internet(commands.Cog):
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):
"""Slash command"""
ctx.prefix = "/" ctx.prefix = "/"
if subreddit == None: if subreddit == None:
return await self._memes(ctx, True) return await self._memes(ctx, True)
@ -94,6 +96,7 @@ class Internet(commands.Cog):
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.")
async def __cat(self, ctx): async def __cat(self, ctx):
"""Slash command"""
return await self._cat(ctx, True) return await self._cat(ctx, True)
@commands.command(name='dog', aliases = ['chien']) @commands.command(name='dog', aliases = ['chien'])
@ -116,6 +119,7 @@ class Internet(commands.Cog):
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.")
async def __dog(self, ctx): async def __dog(self, ctx):
"""Slash command"""
return await self._dog(ctx, True) return await self._dog(ctx, True)
@commands.command(name='sexe', aliases=['sexes', 'nude', 'nudes', 'nsfw']) @commands.command(name='sexe', aliases=['sexes', 'nude', 'nudes', 'nsfw'])
@ -135,6 +139,7 @@ class Internet(commands.Cog):
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):
"""Slash command"""
return await self._sexe(ctx, True) return await self._sexe(ctx, True)
@commands.command(name='news', aliases=['rss']) @commands.command(name='news', aliases=['rss'])
@ -188,6 +193,7 @@ class Internet(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
@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"""
if source == None: if source == None:
return await self._news(ctx, True) return await self._news(ctx, True)
else: else:

View file

@ -492,6 +492,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
return await addReaction(ctx.message, 0) return await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="connect", description = "Se connecte au salon vocal.") @cog_ext.cog_slash(name="connect", description = "Se connecte au salon vocal.")
async def _connect(self, ctx, channel = None): async def _connect(self, ctx, channel = None):
"""Slash command"""
return await self.connect(ctx = ctx, channel = channel, fromSlash = True) return await self.connect(ctx = ctx, channel = channel, fromSlash = True)
@commands.command(aliases=["p"]) @commands.command(aliases=["p"])
@ -549,6 +550,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
return await addReaction(ctx.message, 0) return await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="play", description = "Joue ou met dans la file d'attente le son demandé.") @cog_ext.cog_slash(name="play", description = "Joue ou met dans la file d'attente le son demandé.")
async def _play(self, ctx, son): async def _play(self, ctx, son):
"""Slash command"""
return await self.play(ctx = ctx, query = son, fromSlash = True) return await self.play(ctx = ctx, query = son, fromSlash = True)
@commands.command() @commands.command()
@ -582,6 +584,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, "Tu as voté pour mettre la musique en pause.", delete_after=15) await mySendHidden(ctx, fromSlash, "Tu as voté pour mettre la musique en pause.", delete_after=15)
@cog_ext.cog_slash(name="pause", description = "Met en pause du son en cours.") @cog_ext.cog_slash(name="pause", description = "Met en pause du son en cours.")
async def _pause(self, ctx): async def _pause(self, ctx):
"""Slash command"""
return await self.pause(ctx = ctx, fromSlash = True) return await self.pause(ctx = ctx, fromSlash = True)
@commands.command() @commands.command()
@ -615,6 +618,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, "Tu as voté pour relancer la musique.", delete_after=15) await mySendHidden(ctx, fromSlash, "Tu as voté pour relancer la musique.", delete_after=15)
@cog_ext.cog_slash(name="resume", description = "Reprend la musique en pause.") @cog_ext.cog_slash(name="resume", description = "Reprend la musique en pause.")
async def _resume(self, ctx): async def _resume(self, ctx):
"""Slash command"""
return await self.resume(ctx = ctx, fromSlash = True) return await self.resume(ctx = ctx, fromSlash = True)
@commands.command(aliases=["s"]) @commands.command(aliases=["s"])
@ -648,6 +652,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, f"Tu as voté pour passer le son ({len(player.skip_votes)}/{required}).", delete_after=15) await mySendHidden(ctx, fromSlash, f"Tu as voté pour passer le son ({len(player.skip_votes)}/{required}).", delete_after=15)
@cog_ext.cog_slash(name="skip", description = "Passe le son en cours.") @cog_ext.cog_slash(name="skip", description = "Passe le son en cours.")
async def _skip(self, ctx): async def _skip(self, ctx):
"""Slash command"""
return await self.skip(ctx = ctx, fromSlash = True) return await self.skip(ctx = ctx, fromSlash = True)
@commands.command(aliases=["disconnect", "dc"]) @commands.command(aliases=["disconnect", "dc"])
@ -678,6 +683,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, "Tu as voté pour arrêter d'écouter de la musique.", delete_after=15) await mySendHidden(ctx, fromSlash, "Tu as voté pour arrêter d'écouter de la musique.", delete_after=15)
@cog_ext.cog_slash(name="stop", description = "Stop le son en cours de lecture, supprime la file d'attente et quitte le vocal.") @cog_ext.cog_slash(name="stop", description = "Stop le son en cours de lecture, supprime la file d'attente et quitte le vocal.")
async def _stop(self, ctx): async def _stop(self, ctx):
"""Slash command"""
return await self.stop(ctx = ctx, fromSlash = True) return await self.stop(ctx = ctx, fromSlash = True)
@commands.command(aliases=['v', 'vol']) @commands.command(aliases=['v', 'vol'])
@ -713,6 +719,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await ctx.send(f"Volume réglé sur **{vol}%** par {ctx.author.mention}", delete_after=7) await ctx.send(f"Volume réglé sur **{vol}%** par {ctx.author.mention}", delete_after=7)
@cog_ext.cog_slash(name="volume", description = "Modifie le volume du bot.") @cog_ext.cog_slash(name="volume", description = "Modifie le volume du bot.")
async def _volume(self, ctx, vol: int = None): async def _volume(self, ctx, vol: int = None):
"""Slash command"""
return await self.volume(ctx = ctx, vol = vol, fromSlash = True) return await self.volume(ctx = ctx, vol = vol, fromSlash = True)
@commands.command(aliases=['mix']) @commands.command(aliases=['mix'])
@ -750,6 +757,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, "Tu as voté pour mélanger la liste de lecture.", delete_after=15) await mySendHidden(ctx, fromSlash, "Tu as voté pour mélanger la liste de lecture.", delete_after=15)
@cog_ext.cog_slash(name="shuffle", description = "Mélange les sons en file d'attente. (minimum 3 sons en file d'attente)") @cog_ext.cog_slash(name="shuffle", description = "Mélange les sons en file d'attente. (minimum 3 sons en file d'attente)")
async def _shuffle(self, ctx): async def _shuffle(self, ctx):
"""Slash command"""
return await self.shuffle(ctx = ctx, fromSlash = True) return await self.shuffle(ctx = ctx, fromSlash = True)
@commands.command(hidden = True) @commands.command(hidden = True)
@ -818,6 +826,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
return await addReaction(ctx.message, 0) return await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="equalizer", description = "Change l'égaliseur de musique. (flat/boost/metal/piano)") @cog_ext.cog_slash(name="equalizer", description = "Change l'égaliseur de musique. (flat/boost/metal/piano)")
async def _equalizer(self, ctx, equalizer: str): async def _equalizer(self, ctx, equalizer: str):
"""Slash command"""
return await self.equalizer(ctx = ctx, equalizer = equalizer, fromSlash = True) return await self.equalizer(ctx = ctx, equalizer = equalizer, fromSlash = True)
@commands.command(aliases=['q', 'que']) @commands.command(aliases=['q', 'que'])
@ -847,6 +856,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await paginator.start(ctx) await paginator.start(ctx)
@cog_ext.cog_slash(name="queue", description = "Affiche les sons en attente.") @cog_ext.cog_slash(name="queue", description = "Affiche les sons en attente.")
async def _queue(self, ctx,): async def _queue(self, ctx,):
"""Slash command"""
return await self.queue(ctx = ctx, fromSlash = True) return await self.queue(ctx = ctx, fromSlash = True)
@commands.command(aliases=['np', 'now_playing', 'current']) @commands.command(aliases=['np', 'now_playing', 'current'])
@ -867,6 +877,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
return await addReaction(ctx.message, 0) return await addReaction(ctx.message, 0)
@cog_ext.cog_slash(name="nowplaying", description = "Met à jour l'embed qui affiche les informations sur la chanson en cours si besoin.") @cog_ext.cog_slash(name="nowplaying", description = "Met à jour l'embed qui affiche les informations sur la chanson en cours si besoin.")
async def _nowplaying(self, ctx,): async def _nowplaying(self, ctx,):
"""Slash command"""
return await self.nowplaying(ctx = ctx, fromSlash = True) return await self.nowplaying(ctx = ctx, fromSlash = True)
@commands.command(aliases=['swap']) @commands.command(aliases=['swap'])
@ -917,6 +928,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
return await ctx.send(f"{member.mention} est maintenant le DJ.") return await ctx.send(f"{member.mention} est maintenant le DJ.")
@cog_ext.cog_slash(name="swap_dj", description = "Donne le rôle de DJ à un autre membre dans le salon vocal.") @cog_ext.cog_slash(name="swap_dj", description = "Donne le rôle de DJ à un autre membre dans le salon vocal.")
async def _swap_dj(self, ctx, member: discord.Member = None): async def _swap_dj(self, ctx, member: discord.Member = None):
"""Slash command"""
return await self.swap_dj(ctx = ctx, member = member, fromSlash = True) return await self.swap_dj(ctx = ctx, member = member, fromSlash = True)
@commands.command(name='lyrics', aliases = ['l', 'lyric']) @commands.command(name='lyrics', aliases = ['l', 'lyric'])
@ -985,10 +997,12 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
await mySendHidden(ctx, fromSlash, f"Aucune musique demandé... `{ctx.prefix}lyrics/l/lyrics <song>`.") await mySendHidden(ctx, fromSlash, f"Aucune musique demandé... `{ctx.prefix}lyrics/l/lyrics <song>`.")
@cog_ext.cog_slash(name="lyrics", description = "Affiche les paroles de la musique en cours, ou de la chanson spécifiée.") @cog_ext.cog_slash(name="lyrics", description = "Affiche les paroles de la musique en cours, ou de la chanson spécifiée.")
async def __lyrics(self, ctx, song: str): async def __lyrics(self, ctx, song: str):
"""Slash command"""
return await self._lyrics(ctx = ctx, song = song, fromSlash = True) return await self._lyrics(ctx = ctx, song = song, fromSlash = True)
@commands.command(name='lyricsromanized', aliases = ['lr', 'lyricromanized'], hidden = True) @commands.command(name='lyricsromanized', aliases = ['lr', 'lyricromanized'], hidden = True)
async def _lyricsromanized(self, ctx, *, song: str = None): async def _lyricsromanized(self, ctx, *, song: str = None):
"""Affiche les paroles de la musique en cours ou de la chanson spécifié mais rajouter un 'romanized' à la fin"""
player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx)
if not song and player.is_playing: if not song and player.is_playing:
song = re.sub(r"(\ )?\(.*\)", "", player.current.title) song = re.sub(r"(\ )?\(.*\)", "", player.current.title)

View file

@ -6,6 +6,7 @@ from utils.core import getURLsInString, getMentionInString, isSlash, mySendHidde
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(ReminderDiscord(client)) client.add_cog(ReminderDiscord(client))
class ReminderDiscord(commands.Cog, name="Reminder"): class ReminderDiscord(commands.Cog, name="Reminder"):
@ -68,6 +69,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
Reminder().suppressionReminder(expired[5]) # suppression du rappel Reminder().suppressionReminder(expired[5]) # suppression du rappel
@_reminderLoop.before_loop @_reminderLoop.before_loop
async def __avant_reminderLoop(self): async def __avant_reminderLoop(self):
"""Wait to start the loop until the whole bot is ready"""
await self.client.wait_until_ready() await self.client.wait_until_ready()
@commands.command(name='reminder', aliases=["remind", "remindme", "rappel"]) @commands.command(name='reminder', aliases=["remind", "remindme", "rappel"])
@ -122,10 +124,12 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
await mySendHidden(ctx, fromSlash, embed = embed) await mySendHidden(ctx, fromSlash, embed = embed)
@_reminder.error @_reminder.error
async def _reminder_error(self, ctx, error): async def _reminder_error(self, ctx, error):
"""Error command handler"""
if 'time is a required argument that is missing.' in str(error): if 'time is a required argument that is missing.' in str(error):
await ctx.send("Tu n'as pas spécifié de durée.") await ctx.send("Tu n'as pas spécifié de durée.")
@cog_ext.cog_slash(name="reminder", description = "Met en place un rappel.") @cog_ext.cog_slash(name="reminder", description = "Met en place un rappel.")
async def __reminder(self, ctx, time, reminder = None): async def __reminder(self, ctx, time, reminder = None):
"""Slash command"""
if reminder == None: if reminder == None:
return await self._reminder(ctx, time, True) return await self._reminder(ctx, time, True)
else: else:
@ -162,6 +166,7 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
await message.add_reaction(emoji) await message.add_reaction(emoji)
@cog_ext.cog_slash(name="reminderlist", description = "Affiche la liste des rappels d'un utilisateur.") @cog_ext.cog_slash(name="reminderlist", description = "Affiche la liste des rappels d'un utilisateur.")
async def __reminderlist(self, ctx, userorpage = None): async def __reminderlist(self, ctx, userorpage = None):
"""Slash command"""
if userorpage == None: if userorpage == None:
return await self._reminderlist(ctx, True) return await self._reminderlist(ctx, True)
else: else:
@ -169,12 +174,14 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
@commands.Cog.listener() @commands.Cog.listener()
async def on_raw_reaction_add(self, payload): async def on_raw_reaction_add(self, payload):
"""Triggered when a reaction is added"""
message, embed = await listReaction(self.client, payload) message, embed = await listReaction(self.client, payload)
if message: if message:
await message.edit(embed = embed) await message.edit(embed = embed)
@commands.Cog.listener() @commands.Cog.listener()
async def on_raw_reaction_remove(self, payload): async def on_raw_reaction_remove(self, payload):
"""Triggered when a reaction is removed"""
message, embed = await listReaction(self.client, payload) message, embed = await listReaction(self.client, payload)
if message: if message:
await message.edit(embed = embed) await message.edit(embed = embed)
@ -203,4 +210,5 @@ class ReminderDiscord(commands.Cog, name="Reminder"):
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):
"""Slash command"""
return await self._reminderdelete(ctx, id, True) return await self._reminderdelete(ctx, id, True)

View file

@ -4,6 +4,7 @@ from discord_slash import cog_ext
from utils.core import isSlash, mySendHidden from utils.core import isSlash, mySendHidden
def setup(client): def setup(client):
"""Adding Cog to bot"""
client.add_cog(School(client)) client.add_cog(School(client))
class School(commands.Cog): class School(commands.Cog):
@ -52,12 +53,14 @@ class School(commands.Cog):
await message.add_reaction(emoji = "") await message.add_reaction(emoji = "")
@_appel.error @_appel.error
async def _appel_error(self, ctx, _): async def _appel_error(self, ctx, _):
"""Error command handler"""
# if isinstance(error, commands.CheckFailure): # if isinstance(error, commands.CheckFailure):
# await ctx.send("Tu n'as pas la permission de faire cette commande, demande à un professeur.") # await ctx.send("Tu n'as pas la permission de faire cette commande, demande à un professeur.")
# else: # else:
await ctx.send(f"Une erreur est survenue, syntaxe: `{ctx.prefix}appel [ID salon vocal]`.") await ctx.send(f"Une erreur est survenue, syntaxe: `{ctx.prefix}appel [ID salon vocal]`.")
@cog_ext.cog_slash(name="appel", description = "Fais l'appel.") @cog_ext.cog_slash(name="appel", description = "Fais l'appel.")
async def __appel(self, ctx, voice_channel_id = None): async def __appel(self, ctx, voice_channel_id = None):
"""Slash command"""
ctx.prefix = "/" ctx.prefix = "/"
if voice_channel_id == None: if voice_channel_id == None:
return await self._appel(ctx, True) return await self._appel(ctx, True)
@ -75,6 +78,3 @@ class School(commands.Cog):
if fromSlash != True: if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
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")
@cog_ext.cog_slash(name="getid", description = "Tuto vidéo sur comment récupérer l'ID d'un utilisateur/salon")
async def __getid(self, ctx):
return await self._getid(ctx, True)

View file

@ -9,6 +9,7 @@ from utils.core import mySendHidden, mentionToUser, getChangelogs, getActualVers
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):
"""Adding Cog to bot"""
client.add_cog(Utils(client)) client.add_cog(Utils(client))
class Utils(commands.Cog): class Utils(commands.Cog):
@ -19,6 +20,7 @@ class Utils(commands.Cog):
@commands.command(name='ping') @commands.command(name='ping')
async def _ping(self, ctx, *arg): async def _ping(self, ctx, *arg):
"""Envoie une réponse avec les latences du Bot."""
arg, fromSlash, _ = isSlash(arg) arg, fromSlash, _ = isSlash(arg)
if arg == 'help': if arg == 'help':
@ -41,6 +43,7 @@ class Utils(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
@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"""
ctx.slash_created_at = nowCustom() ctx.slash_created_at = nowCustom()
if arg == None: if arg == None:
return await self._ping(ctx, True) return await self._ping(ctx, True)
@ -64,6 +67,7 @@ class Utils(commands.Cog):
await ctx.send(embed = embed) await ctx.send(embed = embed)
@cog_ext.cog_slash(name="avatar", description = "Affiche ton avatar ou celui que tu mentionnes.") @cog_ext.cog_slash(name="avatar", description = "Affiche ton avatar ou celui que tu mentionnes.")
async def __avatar(self, ctx, user = None): async def __avatar(self, ctx, user = None):
"""Slash command"""
if user == None: if user == None:
return await self._avatar(ctx, True) return await self._avatar(ctx, True)
else: else:
@ -114,9 +118,11 @@ class Utils(commands.Cog):
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, _):
"""Error command handler"""
await ctx.send("Tu n'as pas spécifié de calcul.") await ctx.send("Tu n'as pas spécifié de calcul.")
@cog_ext.cog_slash(name="calc", description = "Calculatrice.") @cog_ext.cog_slash(name="calc", description = "Calculatrice.")
async def __calc(self, ctx, calcul): async def __calc(self, ctx, calcul):
"""Slash command"""
return await self._calc(ctx, calcul, True) return await self._calc(ctx, calcul, True)
@commands.command(name='syntax') @commands.command(name='syntax')
@ -173,6 +179,7 @@ class Utils(commands.Cog):
await mySendHidden(ctx, fromSlash, syntaxe) await mySendHidden(ctx, fromSlash, syntaxe)
@cog_ext.cog_slash(name="syntax", description = "Informations pour bien éditer son texte.") @cog_ext.cog_slash(name="syntax", description = "Informations pour bien éditer son texte.")
async def __syntax(self, ctx): async def __syntax(self, ctx):
"""Slash command"""
return await self._syntax(ctx, True) return await self._syntax(ctx, True)
@commands.command(name='memo', aliases = ['note']) @commands.command(name='memo', aliases = ['note'])
@ -203,10 +210,12 @@ class Utils(commands.Cog):
return await mySendHidden(ctx, fromSlash, "Tu viens de recevoir ton mémo !", delete_after = 5) return await mySendHidden(ctx, fromSlash, "Tu viens de recevoir ton mémo !", delete_after = 5)
@_memo.error @_memo.error
async def _memo_error(self, ctx, error): async def _memo_error(self, ctx, error):
"""Error command handler"""
if str(error) == "text is a required argument that is missing.": if str(error) == "text is a required argument that is missing.":
await ctx.send(f"Vous devez renseigner un message : `{ctx.prefix}memo/note <message>`.") await ctx.send(f"Vous devez renseigner un message : `{ctx.prefix}memo/note <message>`.")
@cog_ext.cog_slash(name="note", description = "T'envoie un petit memo par message privé.") @cog_ext.cog_slash(name="note", description = "T'envoie un petit memo par message privé.")
async def __memo(self, ctx, memo): async def __memo(self, ctx, memo):
"""Slash command"""
return await self._memo(ctx, memo, True) return await self._memo(ctx, memo, True)
@commands.command(name='infos', aliases = ['info']) @commands.command(name='infos', aliases = ['info'])
@ -269,6 +278,7 @@ class Utils(commands.Cog):
await ctx.send(embed = embed) await ctx.send(embed = embed)
@cog_ext.cog_slash(name="infos", description = "Donne des infos sur le bot.") @cog_ext.cog_slash(name="infos", description = "Donne des infos sur le bot.")
async def __infos(self, ctx): async def __infos(self, ctx):
"""Slash command"""
ctx.prefix = "/" ctx.prefix = "/"
return await self._infos(ctx, True) return await self._infos(ctx, True)
@ -326,6 +336,7 @@ class Utils(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
@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"""
ctx.prefix = "/" ctx.prefix = "/"
return await self._amongus(ctx, map, True) return await self._amongus(ctx, map, True)
@ -359,6 +370,7 @@ class Utils(commands.Cog):
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.")
async def __whois(self, ctx, user: discord.Member = None): async def __whois(self, ctx, user: discord.Member = None):
"""Slash command"""
ctx.prefix = "/" # pas sûr que ce soit utile ctx.prefix = "/" # pas sûr que ce soit utile
if user == None: if user == None:
return await self._whois(ctx, True) return await self._whois(ctx, True)
@ -415,6 +427,7 @@ class Utils(commands.Cog):
prop5 = None, prop6 = None, prop7 = None, prop8 = None, prop9 = None, prop10 = None, prop5 = None, prop6 = None, prop7 = None, prop8 = None, prop9 = None, prop10 = None,
prop11 = None, prop12 = None, prop13 = None, prop14 = None, prop15 = None, prop16 = None, prop11 = None, prop12 = None, prop13 = None, prop14 = None, prop15 = None, prop16 = None,
prop17 = None, prop18 = None, prop19 = None, prop20 = None): prop17 = None, prop18 = None, prop19 = None, prop20 = None):
"""Slash command"""
ctx.prefix = "/" ctx.prefix = "/"
args = [question, prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8, args = [question, prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8,
prop9, prop10, prop11, prop12, prop13, prop14, prop15, prop16, prop9, prop10, prop11, prop12, prop13, prop14, prop15, prop16,
@ -452,6 +465,7 @@ class Utils(commands.Cog):
return await ctx.message.delete() return await ctx.message.delete()
@cog_ext.cog_slash(name="avis", description = "Demande un avis, si 2 arguments, alors l'argument 1 est le titre, sinon c'est la demande.") @cog_ext.cog_slash(name="avis", description = "Demande un avis, si 2 arguments, alors l'argument 1 est le titre, sinon c'est la demande.")
async def __avis(self, ctx, titreoudemande, demande = None): async def __avis(self, ctx, titreoudemande, demande = None):
"""Slash command"""
args = [titreoudemande, demande] args = [titreoudemande, demande]
if args[1] == None: if args[1] == None:
args = args[:1] args = args[:1]
@ -484,6 +498,7 @@ class Utils(commands.Cog):
await ctx.send(embed = embed) await ctx.send(embed = embed)
@cog_ext.cog_slash(name="changelogs", description = "Affiche les changements de la dernière version ou d'une version précise.") @cog_ext.cog_slash(name="changelogs", description = "Affiche les changements de la dernière version ou d'une version précise.")
async def __changelogs(self, ctx, version = None): async def __changelogs(self, ctx, version = None):
"""Slash command"""
if version == None: if version == None:
return await self._changelogs(ctx, True) return await self._changelogs(ctx, True)
else: else:
@ -499,4 +514,5 @@ class Utils(commands.Cog):
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):
"""Slash command"""
return await self._minecraft(ctx, True) return await self._minecraft(ctx, True)

View file

@ -28,24 +28,29 @@ print("Terminé !")
@client.event @client.event
async def on_connect(): async def on_connect():
"""Triggered when the bot is connected to Discord"""
print(f"Connecté !") print(f"Connecté !")
@client.event @client.event
async def on_disconnect(): async def on_disconnect():
"""Triggered when the bot is disconnected to Discord"""
print(f"Déconnecté.") print(f"Déconnecté.")
@client.event @client.event
async def on_resumed(): async def on_resumed():
"""Triggered when the bot is reconnected to Discord"""
print(f"Reconnecté !") print(f"Reconnecté !")
@client.event @client.event
async def on_ready(): async def on_ready():
"""Triggered when the bot is ready to operate"""
await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = f"{customPrefix}help", type = discord.ActivityType.playing)) await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = f"{customPrefix}help", type = discord.ActivityType.playing))
Reminder().creationTable() Reminder().creationTable()
print("Bot prêt.") print("Bot prêt.")
@client.event @client.event
async def on_command_error(ctx, error): async def on_command_error(ctx, error):
"""Triggered when a command enconter an 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:
@ -53,6 +58,7 @@ async def on_command_error(ctx, error):
@client.event @client.event
async def on_message(message): async def on_message(message):
"""Triggered a message is received"""
await client.process_commands(message) await client.process_commands(message)
if message.author == client.user: if message.author == client.user: