-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
184 lines (167 loc) · 5.74 KB
/
main.py
File metadata and controls
184 lines (167 loc) · 5.74 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import os
import sqlite3
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
class NexusGuardBot(commands.Bot):
async def setup_hook(self):
# Create database if it doesn't exist
conn = sqlite3.connect('bot.db')
conn.execute(
'''CREATE TABLE IF NOT EXISTS economy (
user_id INTEGER,
guild_id INTEGER,
balance INTEGER DEFAULT 0,
PRIMARY KEY (user_id, guild_id)
)'''
)
conn.execute(
'''CREATE TABLE IF NOT EXISTS warnings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER,
guild_id INTEGER,
reason TEXT,
moderator_id INTEGER,
timestamp REAL
)'''
)
conn.execute(
'''CREATE TABLE IF NOT EXISTS settings (
guild_id INTEGER,
key TEXT,
value TEXT,
PRIMARY KEY (guild_id, key)
)'''
)
conn.execute(
'''CREATE TABLE IF NOT EXISTS mod_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
guild_id INTEGER,
action TEXT,
user_id INTEGER,
mod_id INTEGER,
reason TEXT,
timestamp REAL
)'''
)
conn.execute(
'''CREATE TABLE IF NOT EXISTS reputation (
user_id INTEGER,
guild_id INTEGER,
xp INTEGER DEFAULT 0,
level INTEGER DEFAULT 1,
last_xp_time REAL DEFAULT 0,
PRIMARY KEY (user_id, guild_id)
)'''
)
conn.execute(
'''CREATE TABLE IF NOT EXISTS jobs (
job_id TEXT PRIMARY KEY,
name TEXT,
min_pay INTEGER,
max_pay INTEGER,
required_level INTEGER
)'''
)
# Pre-seed some jobs if empty
cursor = conn.cursor()
cursor.execute("SELECT count(*) FROM jobs")
if cursor.fetchone()[0] == 0:
jobs_data = [
("dishwasher", "Dishwasher", 50, 100, 1),
("cashier", "Cashier", 100, 200, 5),
("manager", "Manager", 300, 500, 10),
("ceo", "CEO", 1000, 2000, 25)
]
cursor.executemany("INSERT INTO jobs VALUES (?,?,?,?,?)", jobs_data)
# Cooldowns table for economy commands
conn.execute(
'''CREATE TABLE IF NOT EXISTS cooldowns (
user_id INTEGER,
guild_id INTEGER,
command TEXT,
last_used REAL,
PRIMARY KEY (user_id, guild_id, command)
)'''
)
# Investments table
conn.execute(
'''CREATE TABLE IF NOT EXISTS investments (
user_id INTEGER,
guild_id INTEGER,
amount INTEGER DEFAULT 0,
invested_at REAL,
PRIMARY KEY (user_id, guild_id)
)'''
)
# Giveaways table
conn.execute(
'''CREATE TABLE IF NOT EXISTS giveaways (
message_id INTEGER PRIMARY KEY,
channel_id INTEGER,
guild_id INTEGER,
host_id INTEGER,
winner_count INTEGER,
prize TEXT,
end_time REAL,
ended INTEGER DEFAULT 0
)'''
)
# Starboard entries
conn.execute(
'''CREATE TABLE IF NOT EXISTS starboard_entries (
original_message_id INTEGER PRIMARY KEY,
starboard_message_id INTEGER,
channel_id INTEGER,
guild_id INTEGER
)'''
)
# Suggestions table
conn.execute(
'''CREATE TABLE IF NOT EXISTS suggestions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
guild_id INTEGER,
user_id INTEGER,
message_id INTEGER,
content TEXT,
status TEXT DEFAULT 'Pending'
)'''
)
conn.commit()
conn.close()
# Load cogs
await self.load_extension('cogs.moderation')
await self.load_extension('cogs.economy')
await self.load_extension('cogs.leaderboard')
await self.load_extension('cogs.games')
await self.load_extension('cogs.help')
await self.load_extension('cogs.errors')
await self.load_extension('cogs.support')
await self.load_extension('cogs.config')
await self.load_extension('cogs.leveling')
await self.load_extension('cogs.dashboard')
await self.load_extension('cogs.ai')
await self.load_extension('cogs.welcome')
await self.load_extension('cogs.reactionroles')
await self.load_extension('cogs.polls')
await self.load_extension('cogs.utility')
await self.load_extension('cogs.automod')
await self.load_extension('cogs.giveaway')
await self.load_extension('cogs.starboard')
await self.load_extension('cogs.suggestions')
intents = discord.Intents.default()
intents.message_content = True
bot = NexusGuardBot(command_prefix='!', intents=intents, help_command=None)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user} ready in {len(bot.guilds)} guilds')
print("All cogs loaded!")
await bot.change_presence(
activity=discord.Game(name='!help | NexusGuard')
)
if __name__ == '__main__':
token = os.getenv('DISCORD_TOKEN')
if not token:
raise RuntimeError('DISCORD_TOKEN not set in environment.')
bot.run(token)