#Buttons...

1 messages · Page 1 of 1 (latest)

lilac drum

Built buttons into my slash command, they output correctly!.
However once I added the event into interactionCreate event - The command now no longer works.
Event:

onst { Events } = require('discord.js');

module.exports = {
  name: Events.InteractionCreate,
  once: false,
  async execute(interaction) {
    if (!interaction.isChatInputCommand()) return;
    if (!interaction.isButton()) return;

    const command = interaction.client.commands.get(interaction.commandName);

    if (!command) {
      console.error(
        `No command matching ${interaction.commandName} was found.`
      );
      return;
    }

    try {
      await command.execute(interaction);
    } catch (error) {
      console.error(error);
      if (interaction.replied || interaction.deferred) {
        await interaction.followUp({
          content: `There was an error while executing ${interaction.commandName} follow up!`,
          ephemeral: true,
        });
      } else {
        await interaction.reply({
          content: `There was an error while executing ${interaction.commandName} reply!`,
          ephemeral: true,
        });
      }
    }
  },
};

The issue is adding:
if (!interaction.isButton()) return;

There are no errors in the terminal, the bot doesn't crash - Nothing to tell me as to why this stops my slashCommand from working.

Ultimately I want to be able to edit the embed the command outputs with the user who interacted with the button.