AttributeError: 'Interaction' object has no attribute 'edit_message'
Summary
Error when editing the message using a dropdown
Reproduction Steps
make a dropdown by subclassing discord.ui.View, then make if statements and in those add await interaction.edit_message()
Minimal Reproducible Code
import discord
from discord import message
from discord.ext import commands
from discord.ui.select import select
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_message(content = 'opt1')
elif select.values[0] == 'admin':
await interaction.edit_message(content ='opt2')
class HelpCommand(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def help(self, ctx, cmd = None):
await ctx.send('test test test', view = HelpView(timeout=10))
Expected Results
Expected result is that it edits the message with the given string, in this case "opt1" or "opt2"
Actual Results
Ignoring exception in view
Intents
intents = discord.Intents.all()
System Information
- Python v3.9.6-final
- py-cord v2.0.0-alpha
- py-cord pkg_resources: v2.0.0a4433+gf51a1ae6
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.22499
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
an interaction cannot edit the message, you need to call edit on the message itself
Duplicate of #444
You might be looking for InteractionResponse.edit_message or interaction.response.edit_message instead (just because these methods are similar)...