-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
55 lines (44 loc) · 2.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import discord
from discord import app_commands
# Ici j'importe les fichiers où l'on a défini les commandes
import fun
import mod
import utils
# Je définis les variables essentiels du Bot ici :
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
# Ici j'ajoute les commandes définient dans les autres fichiers :
for command in fun.fun_commands:
tree.command(name=command['name'], description=command['description'])(command['func'])
print(f"Command {command['name']} has been set up with the func {command['func']} !")
for command in mod.mod_commands:
tree.command(name=command['name'], description=command['description'])(command['func'])
print(f"Command {command['name']} has been set up with the func {command['func']} !")
for command in utils.utils_commands:
tree.command(name=command['name'], description=command['description'])(command['func'])
print(f"Command {command['name']} has been set up with the func {command['func']} !")
@client.event
async def on_ready():
"""
Cette commande s'éxecute lorsque le bot a démarré :
- Elle change son son statut + son activité;
- Elle synchronise "l'arbre" des commandes;
"""
await tree.sync()
await client.change_presence(activity=discord.Game("/game"), status=discord.Status.online)
print(f"We have logged in as {client.user}")
@tree.error
async def on_command_error(interaction, error):
"""
Cette commande s'éxecute lorsque le Bot reçoit une erreur :
- Pour l'instant elle ne traite que les erreurs de permissions;
"""
if isinstance(error, app_commands.MissingPermissions):
embed = discord.Embed(title=":x: | Tu n'as pas la permission d'utiliser cette commande !", color=discord.Color.red())
await interaction.response.send_message(embed=embed, ephemeral=True)
return
raise error
TOKEN = "OTIxMTQ1MzU1NTYxNzQyMzk2.GHPvKg.Oc1GGhhRCaIrgduhV1oct6uTYZ3WpALrjf-pHM "
print("Launch of the Client...")
client.run(TOKEN)