-
Notifications
You must be signed in to change notification settings - Fork 1
/
embedbot.py
82 lines (64 loc) · 2.26 KB
/
embedbot.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from misc.adapter import log
from misc.config import Config
from modules.say import SayModule
import discord
class EmbedBot:
def __init__(self):
self.bot = None
self.modules = []
self.config = Config()
async def on_ready(self):
"""Event handler for when the bot is ready."""
log("Initializing bot presence...")
game = self.config.get("game-presence", "Skynet")
await self.bot.change_presence(activity=discord.Game(name=game))
log("Loading modules...")
self.modules = [
SayModule(self, self.bot)
]
log("Initialization complete.")
async def on_message_delete(self, msg):
"""Event handler for when a message is deleted.
Args:
msg: The message that was deleted.
"""
for module in self.modules:
await module.on_message_delete(msg)
async def on_message_edit(self, before, after):
"""Event handler for when a message is edited.
Args:
before: The message before the edit.
after: The message after the edit.
"""
for module in self.modules:
await module.on_message_edit(before, after)
async def on_member_join(self, member):
"""Event handler for when a member joins the server.
Args:
member: The member that joined the server.
"""
for module in self.modules:
await module.on_member_join(member)
async def on_member_remove(self, member):
"""Event handler for when a member leaves the server.
Args:
member: The member that left the server.
"""
for module in self.modules:
await module.on_member_remove(member)
async def on_message(self, msg):
"""Event handler for messages.
Args:
msg: The message.
"""
for module in self.modules:
await module.on_message(msg)
async def handle_command(self, msg, cmd, args):
"""Event handler for commands.
Args:
msg: The message that contains the command.
cmd: The command.
args: The arguments provided.
"""
for module in self.modules:
await module.on_command(msg, cmd, args)