This repository has been archived on 2022-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
KassouBot/src/main.py

56 lines
1.9 KiB
Python
Raw Normal View History

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-07 23:55:19 +02:00
from os import environ
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())
slash = SlashCommand(client, sync_commands = True)
2020-11-29 11:39:41 +01:00
client.load_extension("cogs.help")
client.load_extension("cogs.utils")
client.load_extension("cogs.internet")
client.load_extension("cogs.music")
client.load_extension("cogs.games")
client.load_extension("cogs.fun")
2021-05-15 20:07:49 +02:00
client.load_extension("cogs.school")
2021-06-07 00:02:34 +02:00
client.load_extension("cogs.citation")
client.load_extension("cogs.confreriedukassoulait") # you can remove this cogs, only for my private guild
2021-06-03 12:21:00 +02:00
Reminder().creationTable()
2021-05-28 13:52:37 +02:00
print("Terminé !")
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
async def on_ready():
await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = f"{customPrefix}help", type = discord.ActivityType.playing))
2020-11-29 11:39:41 +01:00
print("Bot prêt.")
@client.event
async def on_command_error(ctx, error):
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:
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'])