-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
45 lines (37 loc) · 1.01 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
# bot.py
import nextcord
from nextcord.ext import commands
import os
from dotenv import load_dotenv
import mysql.connector
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
DB_HOST = os.getenv('DB_HOST')
DB_USER = os.getenv('DB_USER')
DB_PASSWORD = os.getenv('DB_PASSWORD')
DB_NAME = os.getenv('DB_NAME')
intents = nextcord.Intents.default()
intents.members = True # Enable member intents
bot = commands.Bot(command_prefix='!', intents=intents)
# Database connection
def get_db_connection():
return mysql.connector.connect(
host=DB_HOST,
user=DB_USER,
password=DB_PASSWORD,
database=DB_NAME
)
bot.db = get_db_connection()
# Load cogs
initial_extensions = [
'bot.cogs.on_join',
'bot.cogs.custom_commands',
'bot.commands.command_guild_settings',
'bot.commands.command_test',
'bot.commands.command_captcha',
'bot.events.on_join_listener'
]
if __name__ == '__main__':
for extension in initial_extensions:
bot.load_extension(extension)
bot.run(TOKEN)