-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (42 loc) · 1.44 KB
/
main.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
import asyncio
import logging
from discord import Intents
from discord.ext.commands import Context
from cheems.pics_cog import PicsCog
from cheems.config import config
from discord.ext import commands
from cheems.help_cog import HelpCog
from cheems.markov import models_xml
from cheems.markov_cog import MarkovCog
from cheems.proactive_markov_cog import ProactiveMarkovCog
from cheems.proactive_react_cog import ProactiveReactCog
from cheems.reaction import reactions
logger = logging.getLogger('cheems')
models_xml.preload_models()
reactions.preload_models()
intents = Intents.default()
intents.messages = True
intents.message_content = True
bot = commands.Bot(command_prefix='.', intents=intents)
# Runs when Bot Successfully Connects
@bot.event
async def on_ready():
logger.info(f'{bot.user} successfully logged in!')
@bot.event
async def on_command_error(ctx: Context, error):
# don't log errors for commands from other bots
if ctx.cog is not None:
logger.error(f'{ctx.cog.qualified_name} error: {error}')
async def main():
bot.remove_command('help')
async with bot:
await bot.add_cog(MarkovCog(bot))
await bot.add_cog(ProactiveMarkovCog(bot))
await bot.add_cog(ProactiveReactCog(bot))
await bot.add_cog(HelpCog(bot))
await bot.add_cog(PicsCog(bot))
await bot.start(config['discord_token'])
try:
asyncio.run(main())
except Exception:
logger.exception("Couldn't run bot")