-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
32 lines (25 loc) · 863 Bytes
/
bot.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
import discord
from discord.ext import commands
from dotenv import load_dotenv
import os
intents = discord.Intents.default()
intents.message_content = True # Reading messages
bot = commands.Bot(command_prefix='!', intents=intents) # Creating bot intent
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
# Asynchronous setup hook for cog loading
async def load_cogs():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
try:
await bot.load_extension(f'cogs.{filename[:-3]}')
print(f'Loaded {filename}')
except Exception as e:
print(f'Failed to load {filename}: {e}')
@bot.event
async def setup_hook():
await load_cogs()
load_dotenv()
discord_token = os.getenv('DISCORD_TOKEN')
bot.run(discord_token)