diff options
| author | 2020-06-12 17:23:26 +0200 | |
|---|---|---|
| committer | 2020-06-12 17:37:57 +0200 | |
| commit | 44e30289d9682a92ef6e6d2ca8e9cf9b669ad65c (patch) | |
| tree | a9ffcdfb1dfdf40321b8ce0586979e5a89f25707 | |
| parent | Incidents: implement `archive` method (diff) | |
Incidents: implement `make_confirmation_task` method
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/moderation/incidents.py | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/bot/cogs/moderation/incidents.py b/bot/cogs/moderation/incidents.py index 8781d6749..2186530d9 100644 --- a/bot/cogs/moderation/incidents.py +++ b/bot/cogs/moderation/incidents.py @@ -145,6 +145,21 @@ class Incidents(Cog):              log.debug("Message archived successfully!")              return True +    def make_confirmation_task(self, incident: discord.Message, timeout: int = 5) -> asyncio.Task: +        """ +        Create a task to wait `timeout` seconds for `incident` to be deleted. + +        If `timeout` passes, this will raise `asyncio.TimeoutError`, signaling that we haven't +        been able to confirm that the message was deleted. +        """ +        log.debug(f"Confirmation task will wait {timeout=} seconds for {incident.id=} to be deleted") +        coroutine = self.bot.wait_for( +            event="raw_message_delete", +            check=lambda payload: payload.message_id == incident.id, +            timeout=timeout, +        ) +        return self.bot.loop.create_task(coroutine) +      async def resolve_message(self, message_id: int) -> t.Optional[discord.Message]:          """          Get `discord.Message` for `message_id` from cache, or API. | 
