pycord icon indicating copy to clipboard operation
pycord copied to clipboard

Dropdown menus dont work with if statements

Open pratheek78 opened this issue 5 years ago • 5 comments

Summary

There is an "unknown webhook" error when i try to use a dropdown.

Reproduction Steps

Subclass discord.ui.View and make a dropdown menu. Then make 5 options and assign a value to each of them. Then, make if statements to edit the original message when the user reacts to a particular option. in my case, i had made only 2, because i was only testing. Then, run the command and react with an option(i reacted to the first one, since it had an if statement.

Minimal Reproducible Code

class HelpView(discord.ui.View):
    @discord.ui.select(placeholder = 'Select A Command Category Here', min_values = 1, max_values = 1, options = [
     discord.SelectOption(label = 'Moderation', description = "Shows Info About All the moderation commands.", emoji = '🔨', value= 'moderation'),
     discord.SelectOption(label = 'Administration', description = "Shows all the admin commands. Not A Lot of stuff here.", emoji = '⚙️', value = 'admin'),
     discord.SelectOption(label = 'Information', description = "Shows All the Info Commands", emoji = '❓' , value = 'info'),
     discord.SelectOption(label = 'Fun', description = "Shows All the Fun Commands", emoji = '🎠', value= 'fun'),
     discord.SelectOption(label = "Misc", description = "Shows the Misc Commands", emoji = '🎭', value='misc')
    ])
    async def select_callback(self, select: discord.ui.Select, interaction: discord.Interaction):
        if select.values[0] == 'moderation':
            await interaction.edit_original_message(content = 'mod help test opt1')
        
        elif select.values[0] == 'admin':
            await interaction.edit_original_message(content ='admin help test opt2')

Expected Results

expected result is for it to edit the message with the given options.

Actual Results

I get this error, even though im not using ANY webhooks. neither in the channel, nor in the code: Ignoring exception in view for item <Select placeholder='Select A Command Category Here' min_values=1 max_values=1 options=[<SelectOption label='Moderation' value='moderation' description='Shows Info About All the moderation commands.' emoji= default=False>, <SelectOption label='Administration' value='admin' description='Shows all the admin commands. Not A Lot of stuff here.' emoji= default=False>, <SelectOption label='Information' value='info' description='Shows All the Info Commands' emoji= default=False>, <SelectOption label='Fun' value='fun' description='Shows All the Fun Commands' emoji= default=False>, <SelectOption label='Misc' value='misc' description='Shows the Misc Commands' emoji= default=False>] disabled=False>: Traceback (most recent call last): File "C:\Python Installation\Python39\lib\site-packages\discord\ui\view.py", line 365, in scheduled_task await item.callback(interaction) File "c:\Users\prath\Desktop\Python\Projects\discord bot\cogs\help.py", line 16, in select_callback await interaction.edit_original_message(content = 'mod help test opt1') File "C:\Python Installation\Python39\lib\site-packages\discord\interactions.py", line 334, in edit_original_message data = await adapter.edit_original_interaction_response( File "C:\Python Installation\Python39\lib\site-packages\discord\webhook\async.py", line 189, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

Intents

intents = discord.Intents.all()

System Information

  • Python v3.9.6-final
  • py-cord v2.0.0-alpha
    • py-cord pkg_resources: v2.0.0a4148+g2bbf0639
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.22494

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

No response

pratheek78 avatar Nov 12 '21 14:11 pratheek78

Any idea on how to fix this? Its been 2 days

pratheek78 avatar Nov 14 '21 07:11 pratheek78

Discord uses webhooks internally. So it's correct.

Lulalaby avatar Nov 14 '21 07:11 Lulalaby

Any idea on how to fix this? Its been 2 days

I think you can use interaction.response.edit_message instead.

esmaycat avatar Nov 14 '21 07:11 esmaycat

Yes you can use interaction.response.edit_message instead as @MhmCats told

ThatGenZGamer48 avatar Nov 14 '21 09:11 ThatGenZGamer48

i believe it said that wasnt a method in interaction, but i'll try it

pratheek78 avatar Nov 14 '21 14:11 pratheek78