-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
65 lines (54 loc) · 1.85 KB
/
bot.py
File metadata and controls
65 lines (54 loc) · 1.85 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Import dependencies
import discord # Discord API
from discord.ext import commands
import os # For environment variables
from dotenv import load_dotenv # Load .env
from utils.db import db_ops # Database operations
# Load environment variables
load_dotenv()
# Setup bot
class DinkBot(commands.Bot):
"""A Discord bot with first-tracking, AI capabilities, and utility functions."""
def __init__(self):
intents = discord.Intents.all()
super().__init__(command_prefix='_', case_insensitive=True, intents=intents)
async def setup_hook(self):
# Load all cogs
await self.load_extension('cogs.first')
await self.load_extension('cogs.server')
await self.load_extension('cogs.ai')
await self.load_extension('cogs.utility')
await self.load_extension('cogs.misc')
async def on_ready(self):
print(f"Live: {self.user.name}")
async def on_message(self, message):
if message.author.bot:
return
# Store message in database
message_data = (
message.id,
message.author.id,
message.channel.id,
message.content,
message.created_at
)
db_ops.update_messages(message_data)
await self.process_commands(message)
async def on_message_edit(self, before, after):
if after.author.bot:
return
# Update edited message in database
message_data = (
after.id,
after.author.id,
after.channel.id,
after.content,
after.created_at
)
db_ops.update_messages(message_data)
def main():
bot = DinkBot()
TOKEN = os.getenv('DISCORD_TOKEN')
bot.run(TOKEN)
if __name__ == "__main__":
main()