From c45c3bd22d12086c3657c68212b245904fd70c7c Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 21 Nov 2023 13:58:43 -0600 Subject: [PATCH] [Discord] Set TwentyFourView.timeout when missing permission Set TwentyFourView.timeout to 600 when missing permission to fetch message --- Discord/cogs/24.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Discord/cogs/24.py b/Discord/cogs/24.py index 3056902c13..03f6b0023e 100644 --- a/Discord/cogs/24.py +++ b/Discord/cogs/24.py @@ -28,8 +28,12 @@ async def twenty_four(self, ctx): f"{numbers[2]}{CEK}{numbers[3]}{CEK}", view = view ) - # Fetch Message, as InteractionMessage token expires after 15 min. - response = await response.fetch() + # InteractionMessage token expires after 15 min. + try: + response = await response.fetch() + except discord.Forbidden: + view.timeout = 600 + response = await response.edit(view = view) else: response = await ctx.embed_reply( f"{numbers[0]}{CEK}{numbers[1]}{CEK}\n" @@ -95,6 +99,9 @@ def __init__(self, bot, numbers): self.message = None + async def on_timeout(self): + await self.stop() + async def stop(self): self.children[0].disabled = True