-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (53 loc) · 1.81 KB
/
main.py
File metadata and controls
68 lines (53 loc) · 1.81 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
import sched
import time
import discord
from discord import Embed, Color
from discord.ext import commands
from discord.ext.commands import CommandNotFound, MissingPermissions
import KEYS
from checks import NotADeveloper
from database import *
conn = db
cur = conn.cursor()
s = sched.scheduler(time.time, time.sleep)
def get_server_prefix(bot: commands.Bot, message: discord.Message):
if not message.guild:
return '-'
server_settings: ServerSettings = ServerSettings.select().where(ServerSettings.gid == message.guild.id).get()
return commands.when_mentioned_or(server_settings.prefix)(bot, message)
client: commands.Bot = commands.Bot(
command_prefix=get_server_prefix,
)
client.remove_command('help')
async def on_command_error(ctx: commands.Context, exc: BaseException):
print('command error')
if isinstance(exc, CommandNotFound):
pass
print('Unknown command')
# await ctx.send(exc.args[0])
# TODO: uncomment again. currently the manual commands block this.
if isinstance(exc, MissingPermissions):
await ctx.send(
embed=Embed(
description='You need to be an admin to execute this command - sorry',
color=Color.red()))
if isinstance(exc, NotADeveloper):
await ctx.send(
embed=Embed(
description='Oh nice you found an dev only command, but sorry only for devs!',
color=Color.red()))
else:
pass
#raise exc
client.on_command_error = on_command_error
MODULES = [
'modules.eval',
'modules.reactions',
'modules.manual_commands',
'modules.guild',
'modules.stop',
'modules.info',
]
for module in MODULES:
client.load_extension(module)
client.run(KEYS.TOKEN)