Skip to content

Commit 0c8d8aa

Browse files
committed
Added on_load and on_unload
1 parent a01eefd commit 0c8d8aa

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

dico_command/addon.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ def __init__(self, bot: "Bot"):
4747
self.listeners: typing.List[Listener] = [x for x in resp if isinstance(x, Listener)]
4848
self.interactions: typing.List["InteractionCommand"] = [x for x in resp if InteractionCommand is not None and isinstance(x, InteractionCommand)]
4949
self.callbacks: typing.List["ComponentCallback"] = [x for x in resp if ComponentCallback is not None and isinstance(x, ComponentCallback)]
50+
self.on_load()
5051

5152
def __str__(self):
5253
return self.name
54+
55+
def on_load(self):
56+
pass
57+
58+
def on_unload(self):
59+
pass

dico_command/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def unload_addons(self, *addons: typing.Union[str, typing.Type["Addon"]]):
139139
self.interaction.remove_command(t)
140140
for cc in addon.callbacks:
141141
self.interaction.remove_callback(cc)
142+
addon.on_unload()
142143

143144
def load_module(self, import_path: str):
144145
try:

0 commit comments

Comments
 (0)