Trouble replying to slash command interactions

module.exports = {
  name: "test",
  description: "Test command",

  callback: async (client, interaction) => {
    const channel = interaction.channel;

    // Defer reply as ephemeral
    await interaction.deferReply({
      flags: MessageFlags.Ephemeral,
    });

    // Check if user is a staff member
    // If not, send them a fail message, with ephemeral
    const isStaff = false;
    if (!isStaff) {
      return interaction.editReply({
        embeds: [
          new EmbedBuilder()
            .setTitle("❌ Cant run command")
            .setDescription(`You are not a staff member!`)
            .setColor("#e67e22"),
        ],
      });
    }

    // If user is a staff member, send them a success message, without ephemeral
    await interaction.deleteReply(); // remove the ephemeral reply

    // Here i can do channel.send but i want it to actually respond to the interaction
    // Doing followUp now responds to the message which says "Message could not be loaded"
    // editing the reply is not possible, because i cant change the ephemeral value
    // How to make it work nicely, what do you do?
    await interaction.followUp({
      embeds: [
        new EmbedBuilder()
          .setTitle("✅ Success")
          .setDescription(`You've ran the command!`)
          .setColor("#2ecc71"),
      ],
    });
  },
};
Was this page helpful?