-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsantabot2.py
executable file
·58 lines (40 loc) · 1.24 KB
/
santabot2.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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import asyncio
import logging
# noinspection PyPackageRequirements
from discord.ext import commands
from pony import orm
from config import *
import cogs.__shared
logging.basicConfig(level=logging.INFO)
db = orm.Database()
db.bind(**DATABASE)
cogs.__shared.db = db
bot = commands.Bot(command_prefix=COMMAND_PREFIX)
bot.description = (
'This bot allows to conduct a Secret Santa event in Discord guilds! '
'It is specifically optimized for digital presents, such as game codes, gift cards etc, '
'which the bot can send anonymously via DM.'
)
cogs.__shared.bot = bot
@bot.event
async def on_command_error(ctx: commands.Context, error: commands.CommandError):
msg = str(error)
if ctx.guild is not None:
msg = '{} {}'.format(ctx.author.mention, msg)
await ctx.send(msg)
@bot.command(
name='eval',
help='Evaluates the specified Python expression',
hidden=True
)
@commands.is_owner()
async def _eval(ctx, *, expression: str):
result = eval(expression)
if asyncio.iscoroutine(result):
result = await result
await ctx.send(result)
# noinspection PyUnresolvedReferences
from cogs import *
db.generate_mapping(check_tables=True, create_tables=True)
bot.run(DISCORD_TOKEN)