Skip to content

Commit ae4b997

Browse files
committed
feat(cogs): add get_critical_tasks method to Afk for dynamic task registration
- Add get_critical_tasks method to register handle_afk_expiration task - Import CriticalTaskConfig and TaskPriority from task_manager - Enable automatic task registration and monitoring for AFK expiration - Follow new cog-driven task management pattern for utility tasks
1 parent d2f898a commit ae4b997

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tux/cogs/utility/afk.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tux.cogs.utility import add_afk, del_afk
1313
from tux.database.controllers import DatabaseController
1414
from tux.utils.functions import generate_usage
15+
from tux.utils.task_manager import CriticalTaskConfig, TaskPriority
1516

1617
# TODO: add `afk until` command, or add support for providing a timeframe in the regular `afk` and `permafk` commands
1718

@@ -220,6 +221,16 @@ async def _get_expired_afk_entries(self, guild_id: int) -> list[AFKModel]:
220221

221222
return [entry for entry in entries if entry.until is not None and entry.until < current_time]
222223

224+
def get_critical_tasks(self) -> list[CriticalTaskConfig]:
225+
"""Get critical tasks for this cog.
226+
227+
Returns
228+
-------
229+
list[CriticalTaskConfig]
230+
List of critical task configurations
231+
"""
232+
return [CriticalTaskConfig("afk_expiration_handler", "Afk", "handle_afk_expiration", TaskPriority.NORMAL)]
233+
223234

224235
async def setup(bot: Tux) -> None:
225236
await bot.add_cog(Afk(bot))

0 commit comments

Comments
 (0)