forked from AlexFlipnote/discord_bot.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
38 lines (33 loc) 路 1.23 KB
/
index.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
import os, tracemalloc, sys
import discord
import logging
import asyncio
from utils import default
from utils.data import Bot, HelpFormat
from data.mongoDB import MongoDB_Context
from valheim_server.log_dog import ValheimLogDog
# tracemalloc.start()
config = default.config()
default.s_print("Logging in...")
bot = Bot(
command_prefix=config["prefix"], prefix=config["prefix"],
owner_ids=config["owners"], command_attrs=dict(hidden=True), help_command=HelpFormat(),
allowed_mentions=discord.AllowedMentions(roles=False, users=True, everyone=False),
intents=discord.Intents( # kwargs found at https://discordpy.readthedocs.io/en/latest/api.html?highlight=intents#discord.Intents
guilds=True, members=True, messages=True, reactions=True, presences=True
)
)
for file in os.listdir("cogs"):
if file.endswith(".py"):
name = file[:-3]
bot.load_extension(f"cogs.{name}")
logging.info(f'Loaded extension: {name}')
try:
asyncio.get_event_loop().create_task(ValheimLogDog(bot).start())
bot.run(config['token'])
except (KeyboardInterrupt, SystemExit) as e:
default.s_print(f"EXIT RECEIVED: {e}")
sys.exit()
except Exception as e:
default.s_print(f'Some other error? {e}')
sys.exit()