-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
46 lines (37 loc) · 1.44 KB
/
Copy pathbot.py
File metadata and controls
46 lines (37 loc) · 1.44 KB
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
import discord
from discord.ext import commands
import os
import asyncio
# Lire le token du fichier token.txt
with open("token.txt", "r") as f:
TOKEN = f.read().strip()
# Intents nécessaires (vous pouvez les ajuster selon vos besoins)
intents = discord.Intents.default()
intents.message_content = True
# Créer une instance de bot
bot = commands.Bot(command_prefix="!", intents=intents)
async def load_commands():
for filename in os.listdir('./commands'):
if filename.endswith('.py') and filename != '__init__.py':
try:
await bot.load_extension(f'commands.{filename[:-3]}')
except Exception as e:
print(f'Erreur lors du chargement de l\'extension {filename}: {e}')
async def load_listeners():
for filename in os.listdir('./listeners'):
if filename.endswith('.py') and filename != '__init__.py':
try:
await bot.load_extension(f'listeners.{filename[:-3]}')
except Exception as e:
print(f'Erreur lors du chargement de l\'extension {filename}: {e}')
# Définir un événement de démarrage pour confirmer que le bot est connecté
@bot.event
async def on_ready():
print(f'Connecté en tant que {bot.user.name}')
# Fonction principale pour démarrer le bot
async def main():
await load_commands()
await load_listeners()
await bot.start(TOKEN)
# Démarrer le bot en exécutant la fonction main
asyncio.run(main())