Merge branch 'dev-slash' into dev

This commit is contained in:
Mylloon 2021-05-30 13:42:17 +02:00
commit 30aed61b03
9 changed files with 357 additions and 110 deletions

1
.gitignore vendored
View file

@ -1,5 +1,4 @@
.vscode/ .vscode/
update/ update/
src/cogs/music_old.py
src/cogs/__pycache__/ src/cogs/__pycache__/
.envrc .envrc

View file

@ -29,9 +29,10 @@ To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and
## __Add the bot to your server__ ## __Add the bot to your server__
- [This site](https://discordapi.com/permissions.html) allows you to choose which permissions to add by default to the bot. - In the [Discord Dev Portal](https://discord.com/developers/applications) create an application, and make sure it's a `Bot` (third tab).
- Choose *Administrator* so you don't get in over your head. - To invite it, go to the `OAuth2` (second tab) tab, select the scopes `bot` (required) and `applications.commands` (for the slashs commands) and in the bot permissions select `Administrator` (You can select manually at your own risk).
- Copy and paste the ID of your bot in *Client ID* found [here](https://discord.com/developers/applications) and go to the link at the bottom of the page. - You have the link above between the two blocks scope and permissions
- If you need help, you can [join my Discord](https://discord.gg/Z5ePxH4)
## __Features__ ## __Features__

View file

@ -4,3 +4,4 @@ asyncpraw==7.2.0 # reddit
youtube-dl==2021.4.26 # music youtube-dl==2021.4.26 # music
lyricsgenius==3.0.1 # lyrics lyricsgenius==3.0.1 # lyrics
feedparser==6.0.2 # rss feed (news) feedparser==6.0.2 # rss feed (news)
discord-py-slash-command==1.2.0 # slash commands

View file

@ -3,6 +3,7 @@ import re
from discord.ext import commands from discord.ext import commands
from random import randint, choice from random import randint, choice
from datetime import timedelta from datetime import timedelta
from discord_slash import cog_ext
def setup(client): def setup(client):
client.add_cog(Fun(client)) client.add_cog(Fun(client))
@ -14,35 +15,55 @@ 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 len(user) > 0:
if user[-1] == True:
fromSlash = user[-1]
user = user[:-1]
if len(user) == 0:
user = ctx.author user = ctx.author
await ctx.message.add_reaction(emoji = '') 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)} 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:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
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:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
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 = None):
if user == None:
return await self._iq(ctx, True)
else:
return 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):
"""Découvre la probabilité que ces deux personnes se mettent en couple.\n ➡ Syntaxe: {PREFIX}love <User1> <User2>""" """Découvre la probabilité que ces deux personnes se mettent en couple.\n ➡ Syntaxe: {PREFIX}love <User1> <User2>"""
fromSlash = False
if len(users) > 0:
if users[-1] == True:
fromSlash = users[-1]
users = users[:-1]
if len(users) == 2 or len(users) == 1: if len(users) == 2 or len(users) == 1:
UneDemande = False UneDemande = False
if len(users) == 1: if len(users) == 1:
@ -52,7 +73,8 @@ class Fun(commands.Cog):
users.append(ctx.author) users.append(ctx.author)
UneDemande = True UneDemande = True
if users[0] == users[1]: if users[0] == users[1]:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
return await ctx.send("Je suis sûr que cette personne s'aime ! :angry:") return await ctx.send("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)
@ -71,16 +93,19 @@ class Fun(commands.Cog):
else: else:
taille_du_pls_grand = len(user2_CALC) taille_du_pls_grand = len(user2_CALC)
taille_du_ms_grand = len(user1_CALC) taille_du_ms_grand = len(user1_CALC)
coef_amour = round(float(len(list(set(user1_CALC).intersection(user2_CALC))) / taille_du_pls_grand),1) * 100 + ((taille_du_pls_grand-taille_du_ms_grand) * 1.5) * 1.7 coef_amour = round(float(len(list(set(user1_CALC).intersection(user2_CALC))) / taille_du_pls_grand), 1) * 100 + ((taille_du_pls_grand-taille_du_ms_grand) * 1.5) * 1.7
if coef_amour > 100: if coef_amour > 100:
coef_amour = 100 coef_amour = 100
if UneDemande == True: if UneDemande == True:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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)}")
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(f"Erreur! Syntaxe : `{ctx.prefix}love <User1> [User2]`\n") await ctx.send(f"Erreur! Syntaxe : `{ctx.prefix}love <User1> [User2]`\n")
def _retirerDoublons(self, liste): def _retirerDoublons(self, liste):
Newliste = [] Newliste = []
@ -91,25 +116,30 @@ class Fun(commands.Cog):
@_love.error @_love.error
async def _love_error(self, ctx, error): async def _love_error(self, ctx, error):
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.")
async def __love(self, ctx, user1: discord.Member, user2: discord.Member = None):
if user2 != None:
return await self._love(ctx, user1, user2, True)
else:
return await self._love(ctx, user1, True)
@commands.command(name='8ball', aliases=['8b', '8balls']) @commands.command(name='8ball', aliases=['8b', '8balls'])
async def _8ball(self, ctx, *, question): async def _8ball(self, ctx, fromSlash = False):
"""Répond à ta question 🔮.\n ➡ Syntaxe: {PREFIX}8ball/8b <question>""" """Répond à ta question 🔮.\n ➡ Syntaxe: {PREFIX}8ball/8b"""
reponses=["c'est sûr.","il en est décidément ainsi.","incontestablement.","oui sans aucun doute.","tu peux t'y fier.","tel que je le vois, oui.","c'est le plus probable.", reponses=["c'est sûr.","il en est décidément ainsi.","incontestablement.","oui sans aucun doute.","tu peux t'y fier.","tel que je le vois, oui.","c'est le plus probable.",
"cela montre de bonnes perspectives.","certes.","les signes indiquent que oui.","ma réponse est oui.","ta question est trop floue, réessaie.","redemandes plus tard stp.", "cela montre de bonnes perspectives.","certes.","les signes indiquent que oui.","ma réponse est oui.","ta question est trop floue, réessaie.","redemandes plus tard stp.",
"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."]
await ctx.send(f"{ctx.author.mention}, {choice(reponses)}") if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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):
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 🔮.")
@commands.command(name='pileouface', aliases=['pf']) async def __8ball(self, ctx, question):
async def _pileouface(self, ctx): await self._8ball(ctx, True)
"""Pile ou face.\n ➡ Syntaxe: {PREFIX}pileouface/pf"""
await ctx.message.add_reaction(emoji = '')
return await ctx.send(f"{'Pile' if randint(0,1) == 1 else 'Face'} !")
@commands.command(name='mock') @commands.command(name='mock')
async def _mock(self, ctx): async def _mock(self, ctx):

View file

@ -2,6 +2,7 @@ import discord
from discord.ext import commands from discord.ext import commands
from random import randint, choice from random import randint, choice
import asyncio import asyncio
from discord_slash import cog_ext
def setup(client): def setup(client):
client.add_cog(Games(client)) client.add_cog(Games(client))
@ -14,8 +15,14 @@ class Games(commands.Cog):
self.guessing_game = {} self.guessing_game = {}
@commands.command(name='chifumi', aliases = ["shifumi", "ppc"]) @commands.command(name='chifumi', aliases = ["shifumi", "ppc"])
async def _chifumi(self, ctx, *, choix): async def _chifumi(self, ctx, *choix):
"""Un simple Chifumi contre le bot.\n ➡ Syntaxe: {PREFIX}chifumi/shifumi/ppc <pierre/papier/ciseaux>""" """Un simple Chifumi contre le bot.\n ➡ Syntaxe: {PREFIX}chifumi/shifumi/ppc <pierre/papier/ciseaux>"""
fromSlash = False
if len(choix) < 1:
raise ModuleNotFoundError
if choix[-1] == True:
fromSlash = choix[-1]
choix = choix[0]
choix_jeu = ["Pierre ✊", "Papier 🧻", "Ciseaux ✂"] choix_jeu = ["Pierre ✊", "Papier 🧻", "Ciseaux ✂"]
orditxt = choice(choix_jeu) orditxt = choice(choix_jeu)
@ -38,12 +45,15 @@ 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)
await ctx.send(embed = embed) if fromSlash != True:
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(embed = embed)
@_chifumi.error @_chifumi.error
async def _chifumi_error(self, ctx, error): async def _chifumi_error(self, ctx, error):
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>")
async def __chifumi(self, ctx, choix):
return await self._chifumi(ctx, choix, True)
@commands.command(name='plusoumoins', aliases = ['+ou-', '+-']) @commands.command(name='plusoumoins', aliases = ['+ou-', '+-'])
async def _plusoumoins(self, ctx): async def _plusoumoins(self, ctx):
@ -91,3 +101,13 @@ class Games(commands.Cog):
await ctx.send(f"Erreur dans la réponse {ctx.author.mention}, merci de n'écrire qu'un nombre. Tapez `stop` pour arrêter le jeu.") await ctx.send(f"Erreur dans la réponse {ctx.author.mention}, merci de n'écrire qu'un nombre. Tapez `stop` pour arrêter le jeu.")
del self.guessing_game[str(ctx.author.id)] del self.guessing_game[str(ctx.author.id)]
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}.")
@commands.command(name='pileouface', aliases=['pf'])
async def _pileouface(self, ctx, fromSlash = False):
"""Pile ou face.\n ➡ Syntaxe: {PREFIX}pileouface/pf"""
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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)

View file

@ -7,6 +7,7 @@ import os
from discord.ext import commands 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
def setup(client): def setup(client):
client.add_cog(Internet(client)) client.add_cog(Internet(client))
@ -14,7 +15,6 @@ def setup(client):
class Internet(commands.Cog): class Internet(commands.Cog):
"""Commandes relatives à ce qui provient d'internet.""" """Commandes relatives à ce qui provient d'internet."""
def __init__(self, client): def __init__(self, client):
self.client = client self.client = client
@ -36,8 +36,17 @@ class Internet(commands.Cog):
await self._cat(await self.client.get_context(message)) await self._cat(await self.client.get_context(message))
@commands.command(name='memes', aliases = ['meme']) @commands.command(name='memes', aliases = ['meme'])
async def _memes(self, ctx, *, args = None): async def _memes(self, ctx, *args):
"""Envois un meme de reddit.\n ➡ Syntaxe: {PREFIX}memes/meme [subreddit]""" """Envois un meme de reddit.\n ➡ Syntaxe: {PREFIX}memes/meme [subreddit]"""
fromSlash = False
if len(args) > 0:
if args[-1] == True:
fromSlash = args[-1]
args = args[:-1]
if len(args) > 0:
args = args[0]
else:
args = None
if args: # s'il y a un subreddit de défini if args: # s'il y a un subreddit de défini
subredditchoix = args subredditchoix = args
@ -63,7 +72,8 @@ class Internet(commands.Cog):
else: else:
await ctx.send(f"```r/{subredditchoix} pour {ctx.author.name}```\n{submission.url}") await ctx.send(f"```r/{subredditchoix} pour {ctx.author.name}```\n{submission.url}")
message = await ctx.send("```Meme de Reddit```") message = await ctx.send("```Meme de Reddit```")
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await message.add_reaction('👍') await message.add_reaction('👍')
return await message.add_reaction('👎') return await message.add_reaction('👎')
@ -71,6 +81,13 @@ class Internet(commands.Cog):
print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}") print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}")
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})") return await ctx.send(f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})")
@cog_ext.cog_slash(name="meme", description = "Envois un meme de reddit.")
async def __memes(self, ctx, subreddit = None):
if subreddit == None:
return await self._memes(ctx, True)
else:
return await self._memes(ctx, subreddit, True)
def _random_image(self, link): def _random_image(self, link):
temps_requete = int(round(time.time() * 1000)) temps_requete = int(round(time.time() * 1000))
@ -91,7 +108,7 @@ class Internet(commands.Cog):
return (json_data, temps_requete) return (json_data, temps_requete)
@commands.command(name='cat', aliases = ['chat']) @commands.command(name='cat', aliases = ['chat'])
async def _cat(self, ctx): async def _cat(self, ctx, fromSlash = False):
"""Te montre un magnifique chat\n ➡ Syntaxe: {PREFIX}cat/chat""" """Te montre un magnifique chat\n ➡ Syntaxe: {PREFIX}cat/chat"""
if ctx.author.nick: if ctx.author.nick:
@ -102,12 +119,16 @@ class Internet(commands.Cog):
cat = self._random_image("http://aws.random.cat/meow") cat = self._random_image("http://aws.random.cat/meow")
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.")
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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")
async def __cat(self, ctx):
return await self._cat(ctx, True)
@commands.command(name='dog', aliases = ['chien']) @commands.command(name='dog', aliases = ['chien'])
async def _dog(self, ctx): async def _dog(self, ctx, fromSlash = False):
"""Te montre un magnifique chien\n ➡ Syntaxe: {PREFIX}dog/chien""" """Te montre un magnifique chien\n ➡ Syntaxe: {PREFIX}dog/chien"""
if ctx.author.nick: if ctx.author.nick:
@ -118,9 +139,13 @@ class Internet(commands.Cog):
dog = self._random_image("https://dog.ceo/api/breeds/image/random") dog = self._random_image("https://dog.ceo/api/breeds/image/random")
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.")
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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")
async def __dog(self, ctx):
return await self._dog(ctx, True)
@commands.command(name='sexe', aliases=['sexes', 'nude', 'nudes', 'nsfw']) @commands.command(name='sexe', aliases=['sexes', 'nude', 'nudes', 'nsfw'])
async def _sexe(self, ctx, *, choice_of_nsfw = None): async def _sexe(self, ctx, *, choice_of_nsfw = None):
@ -142,8 +167,17 @@ class Internet(commands.Cog):
await ctx.send(f"Désolé mais je n'envois ce genre de message seulement dans les salons NSFW !") await ctx.send(f"Désolé mais je n'envois ce genre de message seulement dans les salons NSFW !")
@commands.command(name='news', aliases=['rss']) @commands.command(name='news', aliases=['rss'])
async def _news(self, ctx, *, arg = ""): async def _news(self, ctx, *arg):
"""Info random dans le domaine de l'informatique\n ➡ Syntaxe: {PREFIX}news/rss [site/liste]""" """Info random dans le domaine de l'informatique\n ➡ Syntaxe: {PREFIX}news/rss [site/liste]"""
fromSlash = False
if len(arg) > 0:
if arg[-1] == True:
fromSlash = arg[-1]
arg = arg[:-1]
if len(arg) > 0:
arg = arg[0]
else:
arg = ""
rss_website = { rss_website = {
"anandtech": "https://www.anandtech.com/rss/", "anandtech": "https://www.anandtech.com/rss/",
@ -185,4 +219,11 @@ class Internet(commands.Cog):
pass pass
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)
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
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.")
async def __news(self, ctx, source = None):
if source == None:
return await self._news(ctx, True)
else:
return await self._news(ctx, source, True)

View file

@ -1,5 +1,6 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from discord_slash import cog_ext
def setup(client): def setup(client):
client.add_cog(School(client)) client.add_cog(School(client))
@ -12,11 +13,22 @@ class School(commands.Cog):
@commands.command(name='appel') @commands.command(name='appel')
# @commands.has_any_role("Professeur", "professeur", "Prof", "prof") # @commands.has_any_role("Professeur", "professeur", "Prof", "prof")
async def _appel(self, ctx, *, voice_channel: int = None): async def _appel(self, ctx, *voice_channel: int):
"""Fais l'appel.\n ➡ Syntaxe: {PREFIX}appel [ID salon vocal]""" """Fais l'appel.\n ➡ Syntaxe: {PREFIX}appel [ID salon vocal]"""
fromSlash = False
if len(voice_channel) > 0:
if voice_channel[-1] == True:
fromSlash = voice_channel[-1]
voice_channel = voice_channel[:-1]
if len(voice_channel) > 0:
voice_channel = voice_channel[0]
else:
voice_channel = None
voice_channels = [] voice_channels = []
voice_channels.extend(ctx.guild.voice_channels) voice_channels.extend(ctx.guild.voice_channels)
await ctx.message.add_reaction(emoji = "") if fromSlash != True:
await ctx.message.add_reaction(emoji = "")
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 ctx.send(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 ctx.send(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}}`.
@ -28,7 +40,7 @@ class School(commands.Cog):
else: else:
return await ctx.send("Tu as spécifié un channel textuelle et non vocal.") return await ctx.send("Tu as spécifié un channel textuelle et non vocal.")
if len(voice_channels) > 0: if len(voice_channels) > 0:
embed = discord.Embed(title = "Réagissez à ce message avec ✋ pour signaler votre présence.", description = f"(attention, je réagis aussi) — Professeur : {ctx.author.mention}") embed = discord.Embed(title = "Réagissez à ce message avec ✋ pour signaler votre présence.", description = f"(attention, je réagis aussi) — Demandeur : {ctx.author.mention}")
for channel in voice_channels: for channel in voice_channels:
prof = [] prof = []
for role in ["Professeur", "professeur", "Prof", "prof"]: for role in ["Professeur", "professeur", "Prof", "prof"]:
@ -52,8 +64,23 @@ class School(commands.Cog):
# 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.")
async def __appel(self, ctx, voice_channel_id = None):
ctx.prefix = "/"
if voice_channel_id == None:
return await self._appel(ctx, True)
else:
try:
return await self._appel(ctx, int(voice_channel_id), True)
except:
pass
@commands.command(name='getid', hidden = True) @commands.command(name='getid', hidden = True)
async def _getid(self, ctx): async def _getid(self, ctx, fromSlash = False):
await ctx.message.add_reaction(emoji = '') """Tuto vidéo sur comment récupérer l'ID d'un utilisateur/salon"""
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
return await ctx.send("Explication sur comment récuperer l'ID d'un utilisateur/salon : https://cdn.discordapp.com/attachments/640312926892195842/780802253258358834/GetID.mp4") return await ctx.send("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

@ -8,6 +8,8 @@ from discord.ext import commands
from random import randint, shuffle from random import randint, shuffle
from datetime import datetime from datetime import datetime
from pytz import timezone from pytz import timezone
from discord_slash import cog_ext
import shlex
def setup(client): def setup(client):
client.add_cog(Utils(client)) client.add_cog(Utils(client))
@ -35,22 +37,49 @@ class Utils(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
@commands.command(name='avatar') @commands.command(name='avatar')
async def _avatar(self, ctx, *, user = '0'): async def _avatar(self, ctx, *user):
"""Affiche ton avatar ou celui que tu mentionnes.\n ➡ Syntaxe: {PREFIX}avatar [user]""" """Affiche ton avatar ou celui que tu mentionnes.\n ➡ Syntaxe: {PREFIX}avatar [user]"""
if user == '0': fromSlash = False
if len(user) > 0:
if user[-1] == True:
fromSlash = user[-1]
user = user[:-1]
if len(user) > 0:
user = user[0]
else:
user = None
if user == None:
user = ctx.author user = ctx.author
else: else:
user = self.client.get_user(int(user[2:-1].replace("!",""))) user = self.client.get_user(int(user[2:-1].replace("!","")))
await ctx.message.add_reaction(emoji = '') 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()) 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)
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.")
async def __avatar(self, ctx, user = None):
if user == None:
return await self._avatar(ctx, True)
else:
return await self._avatar(ctx, user, True)
@commands.command(name='calc') @commands.command(name='calc')
async def _calc(self, ctx, *, msg): async def _calc(self, ctx, *calcul):
"""Calculatrice.\n ➡ Syntaxe: {PREFIX}calc <calcul>""" """Calculatrice.\n ➡ Syntaxe: {PREFIX}calc <calcul>"""
equation = msg.replace('^', '**').replace('x', '*').replace('×', '*').replace('÷', '/').replace('', '>=').replace('', '<=') fromSlash = False
if len(calcul) > 0:
if calcul[-1] == True:
fromSlash = calcul[-1]
calcul = calcul[:-1]
if len(calcul) > 0:
calcul = calcul[0]
else:
raise ModuleNotFoundError
equation = calcul.replace('^', '**').replace('x', '*').replace('×', '*').replace('÷', '/').replace('', '>=').replace('', '<=')
try: try:
try: try:
if '=' in equation: if '=' in equation:
@ -83,14 +112,18 @@ 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)
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.send(content = None, embed = embed) await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed)
@_calc.error @_calc.error
async def _calc_error(self, ctx, error): async def _calc_error(self, ctx, error):
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.")
async def __calc(self, ctx, calcul):
return await self._calc(ctx, calcul, True)
@commands.command(name='syntax') @commands.command(name='syntax')
async def _syntax(self, ctx): async def _syntax(self, ctx, fromSlash = False):
"""Informations pour bien éditer son texte.""" """Informations pour bien éditer son texte."""
syntaxe = "-----------------------------------------------------\n" syntaxe = "-----------------------------------------------------\n"
syntaxe += discord.utils.escape_markdown("```Js\n") syntaxe += discord.utils.escape_markdown("```Js\n")
@ -132,32 +165,52 @@ class Utils(commands.Cog):
syntaxe += "-----------------------------------------------------\n" syntaxe += "-----------------------------------------------------\n"
syntaxe += discord.utils.escape_markdown(">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n") syntaxe += discord.utils.escape_markdown(">>> 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" syntaxe += ">>> cette ligne est cité\ncelle là aussi (et elles le seront toutes!)\n"
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(syntaxe) await ctx.send(syntaxe)
@cog_ext.cog_slash(name="syntax", description = "Informations pour bien éditer son texte.")
async def __syntax(self, ctx):
return await self._syntax(ctx, True)
@commands.command(name='memo', aliases = ['note']) @commands.command(name='memo', aliases = ['note'])
async def _memo(self, ctx, *, text): async def _memo(self, ctx, *text):
"""T'envoie un petit memo par message privé.\n ➡ Syntaxe: {PREFIX}memo/note <message>""" """T'envoie un petit memo par message privé.\n ➡ Syntaxe: {PREFIX}memo/note <message>"""
fromSlash = False
if len(text) > 0:
if text[-1] == True:
fromSlash = text[-1]
text = text[:-1]
if len(text) > 0:
text = " ".join(text)
else:
raise ModuleNotFoundError
if len(text) <= 5: if len(text) <= 5:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
return await ctx.send("Ta note doit au moins faire 5 caractères.") return await ctx.send("Ta note doit au moins faire 5 caractères.")
elif len(text) >= 2048: elif len(text) >= 2048:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
return await ctx.send("Ta note doit faire moins de 2048 caractères.") return await ctx.send("Ta note doit faire moins de 2048 caractères.")
else: else:
await ctx.message.delete() if fromSlash != True:
await ctx.message.delete()
embed = discord.Embed(description = text, color = discord.Colour.random()) embed = discord.Embed(description = text, color = discord.Colour.random())
embed.set_author(name = f"Mémo noté depuis {ctx.guild.name}", icon_url = ctx.author.avatar_url) embed.set_author(name = f"Mémo noté depuis {ctx.guild.name}", icon_url = ctx.author.avatar_url)
embed.set_footer(text = f'📝 le {datetime.now(pytz.timezone(self.customTimezone)).strftime("%d/%m/%Y à %H:%M:%S")}') embed.set_footer(text = f'📝 le {datetime.now(pytz.timezone(self.customTimezone)).strftime("%d/%m/%Y à %H:%M:%S")}')
await ctx.author.send(embed = embed) await ctx.author.send(embed = embed)
return await ctx.send("Tu viens de recevoir ton mémo !", delete_after = 5) return await ctx.send("Tu viens de recevoir ton mémo !", delete_after = 5)
@_memo.error @_memo.error
async def _note_error(self, ctx, error): async def _memo_error(self, ctx, error):
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}note/memo <message>`.") await ctx.send(f"Vous devez renseigner un message : `{ctx.prefix}memo/note <message>`.")
@cog_ext.cog_slash(name="memo", description = "T'envoie un petit memo par message privé.")
async def __memo(self, ctx, memo):
return await self._memo(ctx, memo, True)
@commands.command(name='infos', aliases = ['info']) @commands.command(name='infos', aliases = ['info'])
async def _infos(self, ctx): async def _infos(self, ctx, fromSlash = False):
"""Donne des infos sur le bot.\n ➡ Syntaxe: {PREFIX}infos/info""" """Donne des infos sur le bot.\n ➡ Syntaxe: {PREFIX}infos/info"""
appinfo = await self.client.application_info() appinfo = await self.client.application_info()
@ -191,21 +244,60 @@ class Utils(commands.Cog):
embed.add_field(name = "Timezone", value = f"`{self.customTimezone}`") embed.add_field(name = "Timezone", value = f"`{self.customTimezone}`")
embed.add_field(name = "Version", value = f"`{version}`") embed.add_field(name = "Version", value = f"`{version}`")
embed.set_footer(text = f"Basé sur discord.py {discord.__version__}") embed.set_footer(text = f"Basé sur discord.py {discord.__version__}")
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed) await ctx.send(embed = embed)
@cog_ext.cog_slash(name="infos", description = "Donne des infos sur le bot.")
async def __infos(self, ctx):
ctx.prefix = "/"
return await self._infos(ctx, True)
def _map_list_among_us(self, map): @commands.command(name='amongus')
maps = {} async def _amongus(self, ctx, *map):
maps["skeld"] = ["skeld", "the skeld", "theskeld"] """Affiche la carte voulue d'Among Us.\n ➡ Syntaxe: {PREFIX}amongus <carte>"""
maps["mira"] = ["mira", "mira hq", "mirahq"] fromSlash = False
maps["polus"] = ["polus"] if len(map) > 0:
maps["airship"] = ["airship", "air ship"] if map[-1] == True:
if map == "all": fromSlash = map[-1]
return maps["skeld"] + maps["mira"] + maps["polus"] + maps["airship"] map = map[:-1]
return maps[map] if len(map) > 0:
map = " ".join(map)
else:
map = "0"
if map.lower() in self._map_list_among_us("mira"):
image = "https://i.imgur.com/6ijrH1h.jpg"
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)
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed)
elif map.lower() in self._map_list_among_us("polus"):
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.set_image(url = image)
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed)
elif map.lower() in self._map_list_among_us("skeld"):
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.set_image(url = image)
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed)
elif map.lower() in self._map_list_among_us("airship"):
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.set_image(url = image)
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
await ctx.send(embed = embed)
else:
await ctx.send(f"`{ctx.prefix}amongus <mira/polus/skeld/airship>`")
@commands.command(name='among', hidden = True) @commands.command(name='among', hidden = True)
async def _among(self, ctx, *, args = ""): async def _among(self, ctx, *, args = ""):
"""Raccourci à la commande amongus"""
if not args == "": if not args == "":
args = args.split() args = args.split()
del args[0] del args[0]
@ -216,40 +308,29 @@ class Utils(commands.Cog):
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 ctx.message.add_reaction(emoji = '')
def _map_list_among_us(self, map):
@commands.command(name='amongus') """Sélecteur de map pour la commande amongus"""
async def _amongus(self, ctx, *, map = "0"): maps = {}
"""Affiche la carte voulue d'Among Us.\n ➡ Syntaxe: {PREFIX}amongus <carte>""" maps["skeld"] = ["skeld", "the skeld", "theskeld"]
if map.lower() in self._map_list_among_us("mira"): maps["mira"] = ["mira", "mira hq", "mirahq"]
image = "https://i.imgur.com/6ijrH1h.jpg" maps["polus"] = ["polus"]
embed = discord.Embed(title = f"Map Mira HQ d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") maps["airship"] = ["airship", "air ship"]
embed.set_image(url = image) if map == "all":
await ctx.send(embed = embed) return maps["skeld"] + maps["mira"] + maps["polus"] + maps["airship"]
await ctx.message.add_reaction(emoji = '') return maps[map]
elif map.lower() in self._map_list_among_us("polus"): @cog_ext.cog_slash(name="amongus", description = "Affiche la carte voulue d'Among Us.")
image = "https://i.imgur.com/mhFmcw3.jpg" async def __amongus(self, ctx, map):
embed = discord.Embed(title = f"Map Polus d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") return await self._amongus(ctx, map, True)
embed.set_image(url = image)
await ctx.send(embed = embed)
await ctx.message.add_reaction(emoji = '')
elif map.lower() in self._map_list_among_us("skeld"):
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.set_image(url = image)
await ctx.send(embed = embed)
await ctx.message.add_reaction(emoji = '')
elif map.lower() in self._map_list_among_us("airship"):
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.set_image(url = image)
await ctx.send(embed = embed)
await ctx.message.add_reaction(emoji = '')
else:
await ctx.send(f"`{ctx.prefix}amongus <mira/polus/skeld/airship>`")
@commands.command(name='whois') @commands.command(name='whois')
async def _whois(self, ctx, *user: discord.Member): async def _whois(self, ctx, *user: discord.Member):
"""Affiche les infos sur l'utilisateur.\n ➡ Syntaxe: {PREFIX}whois [user]""" """Affiche les infos sur l'utilisateur.\n ➡ Syntaxe: {PREFIX}whois [user]"""
fromSlash = False
if len(user) > 0:
if user[-1] == True:
fromSlash = user[-1]
user = user[:-1]
if len(user) <= 1: if len(user) <= 1:
if user == (): if user == ():
user = [ctx.author] user = [ctx.author]
@ -271,9 +352,17 @@ class Utils(commands.Cog):
embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}")
embed.add_field(name = "Est sur le serveur depuis", value = self._ageLayout(self._get_age(user[0].joined_at))) embed.add_field(name = "Est sur le serveur depuis", value = self._ageLayout(self._get_age(user[0].joined_at)))
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
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.")
async def __whois(self, ctx, user: discord.Member = None):
ctx.prefix = "/" # pas sûr que ce soit utile
if user == None:
return await self._whois(ctx, True)
else:
return await self._whois(ctx, user, True)
def _get_age(self, date): def _get_age(self, date):
joursRestants = datetime.now() - date joursRestants = datetime.now() - date
@ -362,6 +451,12 @@ class Utils(commands.Cog):
@commands.command(name='sondage') @commands.command(name='sondage')
async def _sondage(self, ctx, *args): async def _sondage(self, ctx, *args):
"""Fais un sondage.\n ➡ Syntaxe: {PREFIX}sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>" """ """Fais un sondage.\n ➡ Syntaxe: {PREFIX}sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>" """
fromSlash = False
if len(args) > 0:
if args[-1] == True:
fromSlash = args[-1]
args = args[:-1]
args = list(args) args = list(args)
if len(args) > 2: if len(args) > 2:
question = args[0] question = args[0]
@ -394,15 +489,27 @@ class Utils(commands.Cog):
sondage = await ctx.send(embed = embed) sondage = await ctx.send(embed = embed)
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])
return await ctx.message.add_reaction(emoji = '') if fromSlash != True:
return await ctx.message.add_reaction(emoji = '')
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:
return await ctx.send(f'Désolé, mais il manque des arguments : `{ctx.prefix}sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`') return await ctx.send(f'Désolé, mais il manque des arguments : `{ctx.prefix}sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`')
@cog_ext.cog_slash(name="sondage", description = "Fais un sondage.")
async def __sondage(self, ctx, args):
ctx.prefix = "/"
args = shlex.split(args)
return await self._sondage(ctx, *args, True)
@commands.command(name='avis', aliases=['vote']) @commands.command(name='avis', aliases=['vote'])
async def _avis(self, ctx, *args): async def _avis(self, ctx, *args):
"""Demande un avis.\n ➡ Syntaxe: {PREFIX}avis/vote "[Titre]" "<Demande>" """ """Demande un avis.\n ➡ Syntaxe: {PREFIX}avis/vote "[Titre]" "<Demande>" """
fromSlash = False
if len(args) > 0:
if args[-1] == True:
fromSlash = args[-1]
args = args[:-1]
args = list(args) args = list(args)
if len(args) > 2 or len(args) == 0: if len(args) > 2 or len(args) == 0:
return await ctx.send("Désolé, la syntaxe est mauvaise.") return await ctx.send("Désolé, la syntaxe est mauvaise.")
@ -419,11 +526,26 @@ class Utils(commands.Cog):
reactions = ['', '🤷', ''] reactions = ['', '🤷', '']
for i in reactions: for i in reactions:
await message.add_reaction(emoji = i) await message.add_reaction(emoji = i)
return await ctx.message.delete() if fromSlash != True:
return await ctx.message.delete()
@cog_ext.cog_slash(name="avis", description = "Demande un avis.")
async def __avis(self, ctx, args):
args = shlex.split(args)
return await self._avis(ctx, *args, True)
@commands.command(name='reminder', aliases=["remind", "remindme"]) @commands.command(name='reminder', aliases=["remind", "remindme"])
async def _reminder(self, ctx, time, *, reminder): async def _reminder(self, ctx, time, *reminder):
"""Met en place un rappel.\n ➡ Syntaxe: {PREFIX}reminder/remind/remindme <temps (d/h/m/s)>[@] <message> """ """Met en place un rappel.\n ➡ Syntaxe: {PREFIX}reminder/remind/remindme <temps (d/h/m/s)>[@] <message> """
fromSlash = False
if len(reminder) > 0:
if reminder[-1] == True:
fromSlash = reminder[-1]
reminder = reminder[:-1]
if len(reminder) > 0:
reminder = " ".join(reminder)
else:
reminder = None
embed = discord.Embed(color = 0xC41B1B) embed = discord.Embed(color = 0xC41B1B)
seconds = 0 seconds = 0
timestamp = datetime.utcnow() timestamp = datetime.utcnow()
@ -463,7 +585,8 @@ class Utils(commands.Cog):
for i in mentionList: for i in mentionList:
message += f" {i}" message += f" {i}"
try: try:
await ctx.message.add_reaction(emoji = '') if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
except: except:
pass pass
finalEmbed = discord.Embed(description = self._cleanCodeStringWithMentionAndURLs(reminder), timestamp = timestamp, color = discord.Colour.random()) finalEmbed = discord.Embed(description = self._cleanCodeStringWithMentionAndURLs(reminder), timestamp = timestamp, color = discord.Colour.random())
@ -480,3 +603,6 @@ class Utils(commands.Cog):
else: else:
embed.add_field(name="Attention", value="Mauvaise syntaxe : reminder <temps> <message>") embed.add_field(name="Attention", value="Mauvaise syntaxe : reminder <temps> <message>")
await ctx.send(embed = embed) await ctx.send(embed = embed)
@cog_ext.cog_slash(name="reminder", description = "Met en place un rappel.")
async def __reminder(self, ctx, time, reminder):
return await self._reminder(ctx, time, reminder, True)

View file

@ -3,6 +3,7 @@ print("Chargement des extensions & librairie...", end = " ")
import discord import discord
import re import re
import os import os
from discord_slash import SlashCommand
from discord.ext import commands from discord.ext import commands
from random import choice from random import choice
from datetime import datetime from datetime import datetime
@ -11,6 +12,7 @@ customPrefix = os.environ['PREFIX']
customTimezone = os.environ['TIMEZONE'] customTimezone = os.environ['TIMEZONE']
client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all()) client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True)
client.load_extension("cogs.help") client.load_extension("cogs.help")
client.load_extension("cogs.utils") client.load_extension("cogs.utils")