Added coroutine to defer response to interaction

This should compensate for the lag in the bot and fix the menu bug
This commit is contained in:
Vivek Santayana 2022-01-22 13:54:02 +00:00
parent f5097a9d2d
commit be43d3e03a

View File

@ -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)