Home > Software design >  Discord Button interaction
Discord Button interaction

Time:01-10

I use discord.py ver 2.0.1

@bot.command()
async def button(ctx):
    button1 = Button(label='Logout', style=discord.ButtonStyle.green, emoji='<:158667290_184837826776331_547475:1061360212117827745>')

    
    async def callback(interaction):
        await interaction.response.send('Hi')

    button.callback = callback

    view = View()
    view.add_item(button1)
    await ctx.send(view=view)

Nothing if i press at button

CodePudding user response:

await interaction.response.send('Hi')

InteractionResponse.send doesn't exist so you can't expect it to do anything. The method to send a message is InteractionResponse.send_message, as the name implies.

You should've gotten an error message that told you this. If you didn't, you're either swallowing errors in an error handler or you didn't configure logging.

  • Related