Search code examples
node.jsdiscorddiscord.jsdiscord-buttons

Send ephemeral response discord-button


I want to send an ephemeral reply like this

enter image description here

with discord discord-button

What I have tried

client.on('clickButton', async (button) => {
  if (button.id === 'openTicket') {
    await button.reply.defer();
    await button.message.channel.send('Done', {ephemeral: true});
  }
});

Solution

  • i don't have much experience with buttons, but i recommend you to read this: https://discordjs.guide/interactions/buttons.html#deferring-and-updating-the-button-message


    I don't think that button.message.channel.send could have an option for ephemeral response, since it's just sending a message to a channel, not to a specified user, And usually ephemeral exists on "reply" since it know which user it is replying to, and so it can make it ephemeral for him only.

    i'll keep you updated if i found the exact solution.

    But

    For now try to do something like:

    await button.reply({
    content: 'hi',
    ephemeral: true,
    )