-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbot.py
More file actions
64 lines (57 loc) · 2.1 KB
/
bot.py
File metadata and controls
64 lines (57 loc) · 2.1 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
57
58
59
60
61
62
63
64
import config
import logging
import discord
import asyncio
from BotClass import Bot
from commands.Help import Help
from commands.GetStarted import GetStarted
from commands.Setup import Setup
from commands.Calendar import Calendar
from commands.ServerInfo import ServerInfo
logging.basicConfig(level=logging.INFO)
# Create instance of the bot
print("=================================")
print("Initializing Bot and Managers...")
bot = Bot()
print("=================================")
# =====================
# Register commands
# =====================
print("Successfully registered commands:")
bot._commandsManager.register_static_command( Setup )
bot._commandsManager.register_static_command( ServerInfo )
bot._commandsManager.register_command( Help )
bot._commandsManager.register_command( GetStarted )
bot._commandsManager.register_command( Calendar )
print("=================================")
# ==================
# Discord events
# ==================
@bot._client.event
async def on_ready():
print("Bot user: {0.user}".format(bot._client))
# start periodic check loop
# https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html
bot.periodic_update_calendars.start()
bot.periodic_clean_db.start()
# update bot's game status
game = discord.Game("calbot.patrikpapso.com")
await bot._client.change_presence(status=discord.Status.online, activity=game)
print("=================================")
@bot._client.event
async def on_resumed():
print("Bot user: {0.user} RESUMED".format(bot._client))
# start periodic check loop
# https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html
bot.periodic_update_calendars.start()
bot.periodic_clean_db.start()
# update bot's game status
game = discord.Game("calbot.patrikpapso.com")
await bot._client.change_presence(status=discord.Status.online, activity=game)
print("==========RESUMED==========")
@bot._client.event
async def on_message(message):
if message.author != bot._client.user:
await bot._commandsManager.process_message(message)
# run the discord client
bot.run_client(config.bot['token'])