From be43d3e03a021489a3a7c32f30e2d1f5aea86a28 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Sat, 22 Jan 2022 13:54:02 +0000 Subject: [PATCH] Added coroutine to defer response to interaction This should compensate for the lag in the bot and fix the menu bug --- app/cogs/events/secondary/pitch_listener.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/cogs/events/secondary/pitch_listener.py b/app/cogs/events/secondary/pitch_listener.py index ab90ced..07ba9d5 100644 --- a/app/cogs/events/secondary/pitch_listener.py +++ b/app/cogs/events/secondary/pitch_listener.py @@ -17,6 +17,15 @@ class PitchListener(commands.Cog, name='Pitch Listener'): def __init__(self, client): self.client = client + @commands.Cog.listener(name='on_component') + async def _response_defer(self, ctx:ComponentContext): + pitches = yaml_load(pitchesFile) + guildStr = str(ctx.guild.id) + if not pitches.get(guildStr, {}): return # If no pitches for current guild, ignore. + [timeslot] = [*pitches[guildStr]] + if ctx.origin_message.id not in pitches[guildStr][timeslot]['messages'] + [pitches[guildStr][timeslot]['control']]: return # If the context id is not in the pitch menu, ignore + await ctx.defer(hidden = True) + @commands.Cog.listener(name='on_component') async def _pitch_listener(self, ctx:ComponentContext): conf = yaml_load(configFile)