From 242b8c4dc9d572883b87e177e76bd28bcba2d7f9 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Mon, 10 Apr 2023 11:42:27 +0100 Subject: [PATCH 1/2] Fix defer --- trainerdex/discord_bot/modules/leaderboard.py | 1 + trainerdex/discord_bot/modules/mod.py | 3 ++- trainerdex/discord_bot/modules/post.py | 2 ++ trainerdex/discord_bot/modules/profile.py | 2 ++ trainerdex/discord_bot/modules/settings.py | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/trainerdex/discord_bot/modules/leaderboard.py b/trainerdex/discord_bot/modules/leaderboard.py index 36d22fb..8c7d37e 100644 --- a/trainerdex/discord_bot/modules/leaderboard.py +++ b/trainerdex/discord_bot/modules/leaderboard.py @@ -68,6 +68,7 @@ async def leaderboard( stat: str, ) -> None: await ctx.interaction.response.defer() + ctx.interaction.response._responded = True if not ctx.guild: selection = LeaderboardType.GLOBAL.value[0] diff --git a/trainerdex/discord_bot/modules/mod.py b/trainerdex/discord_bot/modules/mod.py index 4dc86bc..c38658d 100644 --- a/trainerdex/discord_bot/modules/mod.py +++ b/trainerdex/discord_bot/modules/mod.py @@ -160,6 +160,7 @@ async def slash__approve( return await ctx.interaction.response.defer() + ctx.interaction.response._responded = True reason = f"{ctx.author} used the /approve command to grant {member} access to this guild." allowed_to_rename: bool = await self.allowed_to_rename(ctx) @@ -288,7 +289,7 @@ async def slash__approve( actions_commited.append(f"Updated {trainer.username} with new stats; {stats_humanize}") if actions_commited: - response: WebhookMessage = await ctx.followup.send( + response: WebhookMessage = await ctx.respond( f"`/approve` run on {member.mention}\n" + "\n".join(actions_commited), wait=True, ) diff --git a/trainerdex/discord_bot/modules/post.py b/trainerdex/discord_bot/modules/post.py index 86e30d5..a175e7b 100644 --- a/trainerdex/discord_bot/modules/post.py +++ b/trainerdex/discord_bot/modules/post.py @@ -108,6 +108,7 @@ async def update_via_slash_command( return await ctx.interaction.response.defer() + ctx.interaction.response._responded = True if image and not kwargs: await ctx.respond( @@ -332,6 +333,7 @@ async def update_via_slash_command( # return # await ctx.interaction.response.defer() + # ctx.interaction.response._responded = True # await ctx.respond( # content=chat_formatting.info( diff --git a/trainerdex/discord_bot/modules/profile.py b/trainerdex/discord_bot/modules/profile.py index fd7b0eb..b155200 100644 --- a/trainerdex/discord_bot/modules/profile.py +++ b/trainerdex/discord_bot/modules/profile.py @@ -37,6 +37,7 @@ async def slash__profile( ) -> None: """Find a profile given a username or user mention.""" await ctx.interaction.response.defer(invisible=False) + ctx.interaction.response._responded = True async with self.client() as client: if username or user: @@ -57,6 +58,7 @@ async def user__profile( user: User, ) -> None: await ctx.interaction.response.defer() + ctx.interaction.response._responded = True async with self.client() as client: trainer = await get_trainer_from_user(client, user) diff --git a/trainerdex/discord_bot/modules/settings.py b/trainerdex/discord_bot/modules/settings.py index aaab4a1..458ce84 100644 --- a/trainerdex/discord_bot/modules/settings.py +++ b/trainerdex/discord_bot/modules/settings.py @@ -110,6 +110,7 @@ async def guild_config__access_roles( return await ctx.interaction.response.defer() + ctx.interaction.response._responded = True guild_config: GuildConfig = await self.config.get_guild(ctx.guild) @@ -175,6 +176,7 @@ async def guild_config__mod_roles(self, ctx: ApplicationContext, action: str, ro return await ctx.interaction.response.defer() + ctx.interaction.response._responded = True guild_config: GuildConfig = await self.config.get_guild(ctx.guild) From 009b9ef66781e1e17aca21b1ed3682ac1235d561 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Sun, 23 Jul 2023 20:48:49 +0100 Subject: [PATCH 2/2] Update mod.py --- trainerdex/discord_bot/modules/mod.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trainerdex/discord_bot/modules/mod.py b/trainerdex/discord_bot/modules/mod.py index c38658d..7552d50 100644 --- a/trainerdex/discord_bot/modules/mod.py +++ b/trainerdex/discord_bot/modules/mod.py @@ -54,7 +54,8 @@ async def allowed_to_assign_roles(self, ctx: ApplicationContext) -> bool: return bool(ctx.author.guild_permissions.manage_roles) def allowed_to_create_profiles(self) -> bool: - return datetime.utcnow() < SHUTDOWN_DATE + # return datetime.utcnow() < SHUTDOWN_DATE + return True def compare_stats(self, x: Update, y: Mapping[str, int | Decimal | None], /) -> bool: x_, y_ = vars(x), deepcopy(y)