This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
51 lines (41 loc) · 1.53 KB
/
bot.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
import discord
import os
import sys
import logging
from discord.ext import commands
from collections import Counter
from models.extension import Extension
from db import db_session, db_engine, Session
log = logging.getLogger(__name__)
class DCUniverseBot(commands.AutoShardedBot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
intents.presences = True
super().__init__('!', case_insensitive=True, intents=intents)
# remove default commands
self.remove_command('help')
# try to load extensions management extension
try:
self.load_extension('extensions.extensionsmanagement')
except Exception:
log.exception(
"Bot failed to load \"extensionsmanagement\"-extension exception")
sys.exit()
# get loaded extension and try to load them
extensions = Extension.loaded()
for extension in extensions:
try:
self.load_extension('extensions.' + extension.name)
except Exception:
extension.isLoaded = False
db_session.commit()
log.exception(
"Bot failed to load the extension \"" + extension.name + "\"")
async def on_ready(self):
await self.change_presence(activity=discord.Activity(
name="Rechnen im Binärsystem",
type=discord.ActivityType.playing
))
def run(self):
super().run(os.getenv('BOT_TOKEN'), reconnect=True)