forked from chamburr/modmail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (44 loc) · 1.77 KB
/
main.py
File metadata and controls
56 lines (44 loc) · 1.77 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
import asyncio
import logging
import sentry_sdk
from discord.ext import commands
import config
from classes.bot import ModMail
from utils.tools import get_guild_prefix
if config.testing is False:
sentry_sdk.init(config.sentry_url)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w")
handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
logger.addHandler(handler)
def _get_guild_prefix(bot2, message):
prefix = get_guild_prefix(bot2, message)
return commands.when_mentioned_or(prefix)(bot2, message)
bot = ModMail(
fetch_offline_members=True,
command_prefix=_get_guild_prefix,
case_insensitive=True,
description="The one and only public ModMail Discord bot.",
help_command=None,
owner_id=config.owner,
heartbeat_timeout=300,
)
c = bot.conn.cursor()
c.execute(
"CREATE TABLE IF NOT EXISTS data "
"(guild bigint NOT NULL PRIMARY KEY, prefix text, category bigint, accessrole text, "
"logging bigint, welcome text, goodbye text, loggingplus integer, pingrole text, blacklist text)"
)
c.execute("CREATE TABLE IF NOT EXISTS premium (user bigint NOT NULL PRIMARY KEY, server text)")
c.execute("CREATE TABLE IF NOT EXISTS banlist (id bigint NOT NULL PRIMARY KEY, type text)")
c.execute("CREATE TABLE IF NOT EXISTS usersettings (user bigint NOT NULL PRIMARY KEY, confirmation int)")
c.execute("CREATE TABLE IF NOT EXISTS stats (commands int, messages int, tickets int)")
c.execute("INSERT INTO stats SELECT 0, 0, 0 WHERE NOT EXISTS (SELECT * FROM stats)")
bot.conn.commit()
@bot.event
async def on_message(_):
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(bot.start_bot())