#Sending messages with Interactions

18 messages · Page 1 of 1 (latest)

old spade
#

I have an unexpected result when sending a message with Intentions.

async execute(interaction) {
    await interaction.channel
      .send(
        `${interaction.user.username} your ping is: ${interaction.client.ws.ping}ms`
      )
      .then(msg => {
        msg.edit(
          `${interaction.user.username} your ping is ${
            interaction.client.ws.ping
          }ms and your latency is: ${
            msg.createdTimestamp - interaction.createdTimestamp
          }ms`
        );
      });
  },

The command will still act as if it is replying, and processes an Ephereal state where only I can see the reply as shown in the images attached. This is unexpected as ultimately, it sends the message, and also edits the sent message to give the correct output, Please see image attached.

eager ridge
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

old spade
#

Note - This will ultimately not be my use case - Just using the ping command currently to work a few things out.

agile vessel
#

You need to reply to the interaction… interaction.reply instead of interaction.channel.send

tacit ridgeBOT
#

Responding to interactions:
#reply immediately respond with a message
#update immediately update the original message (buttons, select menus)
#showModal immediately show a modal (cannot be deferred)
#deferReply/Update respond later (up to 15 minutes)
#followUp post an additional message

The initial response has to happen within 3s of receiving the interaction!

agile vessel
#

One of these needs to happen, can be ephemeral though

old spade
#

So if the only way to respond to commands is through interaction.reply - How do people build commands that output embeds, messages etc without replying to the user?

agile vessel
#

By also replying ephemerally (if slashcommand) or deferUpdate (if MessageComponentInteraction)

old spade
#

ephemerally only toggles whether the user using the command can see the post or everyone though.

#

So that embed was posted by a bot - using a command by someone, that is not "replied" too

#

Which I have replicated here:
But it has adverse consequences in the form of still posting an ephemeral response.

I'm trying to understand how this is done correctly.

agile vessel
old spade
#

Seems like wasted resources to have to do it like this:

#

Ultimately the ping is just an example, not my use case - I guess if that is the only way to do it - Then I'll work with that.

Thanks

agile vessel
#

Well, there’s always the way to actually reply to the command as intended, but you made it very clear you don’t want that

fallen lotus
old spade
fallen lotus
#

It's okay, it happens