Chargement des extensions après que le bot se connecte à Discord

This commit is contained in:
Mylloon 2020-11-09 10:00:06 +01:00
parent eee49784bb
commit f8d3464187

19
main.py
View file

@ -11,14 +11,17 @@ client = commands.Bot(command_prefix = ".", case_insensitive = True, intents = d
@client.event
async def on_connect():
print("Le bot est en ligne.")
print("Connecté.")
print("Chargement des extensions & librairie...")
client.load_extension("cogs.commands")
client.load_extension("cogs.help")
# le status du bot
@client.event
async def on_ready():
await client.change_presence(status = discord.Status.online, activity = discord.Activity(name = "https://code.up8.edu/Anri/bot-licence",
type = discord.ActivityType.competing))
print("Bot chargé à 100%.")
print("Bot prêt.")
@client.event
async def on_raw_reaction_add(payload): # check toutes les nouvelles réactions
@ -78,17 +81,5 @@ async def on_raw_reaction_remove(payload):
role = discord.utils.get(guild.roles, name="L1C2")
await member.remove_roles(role)
# on importe les modules complémentaires situé dans cogs/
try:
client.load_extension("cogs.commands")
except Exception as error:
print(error)
client.remove_command("help")
try:
client.load_extension("cogs.help")
except Exception as error:
print(error)
# pour lancer le bot
client.run(token)