2021-05-28 13:52:37 +02:00
|
|
|
print("Chargement des extensions & librairie...", end = " ")
|
2020-11-29 11:39:41 +01:00
|
|
|
|
2021-05-28 14:13:14 +02:00
|
|
|
import discord
|
2021-06-10 11:15:49 +02:00
|
|
|
from os import environ, listdir
|
2021-05-28 14:03:34 +02:00
|
|
|
from discord_slash import SlashCommand
|
2020-11-29 11:39:41 +01:00
|
|
|
from discord.ext import commands
|
2021-06-03 12:21:00 +02:00
|
|
|
from utils.reminder import Reminder
|
2021-06-07 23:55:19 +02:00
|
|
|
customPrefix = environ['PREFIX']
|
2020-11-29 11:39:41 +01:00
|
|
|
|
2021-05-07 16:44:47 +02:00
|
|
|
client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all())
|
2021-05-29 12:50:55 +02:00
|
|
|
slash = SlashCommand(client, sync_commands = True)
|
2020-11-29 11:39:41 +01:00
|
|
|
|
2021-06-11 11:09:20 +02:00
|
|
|
for file in listdir("cogs"):
|
2021-06-10 11:15:49 +02:00
|
|
|
if file.endswith(".py") and file.startswith("-") == False:
|
|
|
|
client.load_extension(f"cogs.{file[:-3]}")
|
2021-05-28 13:52:37 +02:00
|
|
|
print("Terminé !")
|
2020-12-16 19:26:51 +01:00
|
|
|
|
2020-11-29 11:39:41 +01:00
|
|
|
@client.event
|
|
|
|
async def on_connect():
|
2021-05-28 13:52:37 +02:00
|
|
|
print(f"Connecté !")
|
2020-11-29 11:39:41 +01:00
|
|
|
|
|
|
|
@client.event
|
2021-06-24 13:17:20 +02:00
|
|
|
async def on_disconnect():
|
|
|
|
print(f"Déconnecté.")
|
|
|
|
|
|
|
|
@client.event
|
2021-06-24 22:48:10 +02:00
|
|
|
async def on_resumed():
|
|
|
|
print(f"Reconnecté !")
|
|
|
|
|
|
|
|
@client.event
|
2020-11-29 11:39:41 +01:00
|
|
|
async def on_ready():
|
2021-05-07 16:48:40 +02:00
|
|
|
await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = f"{customPrefix}help", type = discord.ActivityType.playing))
|
2021-06-08 22:15:09 +02:00
|
|
|
Reminder().creationTable()
|
2020-11-29 11:39:41 +01:00
|
|
|
print("Bot prêt.")
|
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_command_error(ctx, error):
|
2021-05-31 20:24:37 +02:00
|
|
|
if not ctx.invoked_with.startswith(customPrefix):
|
2020-11-29 11:39:41 +01:00
|
|
|
print(error)
|
2021-06-08 10:44:56 +02:00
|
|
|
if ctx.message:
|
2021-06-07 21:32:14 +02:00
|
|
|
await ctx.message.add_reaction(emoji = '❓')
|
2020-11-29 11:39:41 +01:00
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_message(message):
|
|
|
|
await client.process_commands(message)
|
|
|
|
|
|
|
|
if message.author == client.user:
|
|
|
|
return
|
|
|
|
|
2021-05-31 20:26:57 +02:00
|
|
|
"""informations concernant le bot lorsqu'il est mentionner"""
|
2020-11-29 11:39:41 +01:00
|
|
|
if client.user.mention == message.content.replace("!",""):
|
|
|
|
ctx = await client.get_context(message)
|
|
|
|
prefix = await client.get_prefix(message)
|
|
|
|
await ctx.send(f">>> Coucou !\nMon préfix est `{prefix}` et ma commande d'aide est `{prefix}help`")
|
|
|
|
|
2021-05-28 13:52:37 +02:00
|
|
|
print("Connexion à Discord...", end = " ")
|
2021-06-07 23:55:19 +02:00
|
|
|
client.run(environ['TOKEN_DISCORD'])
|