#interactionCreate.js doesn't pick up guild commands

23 messages · Page 1 of 1 (latest)

wary portalBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by staff
bold wedge

So I'm trying to make a few commands guild exclusive, the command will show up in the query only in the guild when i type it's name, but when i enter the interaction, i get this

and to try to get around this, i tried something like this

but when i ran the guild command after this, i received this error

i also deploy them in a completely different file, not sure if that was the proper way to do it, but i made a 📁 deploy-guildCommands.js next to my 📁 deploy-commands.js

i know there's probably a better way to do that part, but it works for the most part, only thing that doesn't work is my 📁interactionCreate.js doesn't pick up my guild commands

bold wedge
bold wedge

i know it's line 14, just don't know how to declare that

halcyon oak
bold wedge
halcyon oak

i was told i can have 100 guild commands, and 100 global ?
that's true IIRC

bold wedge
halcyon oak Wdym?

like, how would i make the guild commands? im not sure how to get my interactionCreate.js to read them?

they deploy perfectly fine, and they don't show up in the other servers (which is what i want), but the interaction doesn't work

i have this set in a file i made called deploy-guildCommands.js, so i know they're guild exclusive, just so confused on how to successfully create the interaction?

ykwim? 😅 brain is breaking over this

it's probably the simplest little thing i have to do too lol

halcyon oak

hmm...

// commands is an array of objects.
// each element in commands has a data property, the SlashCommandBuilder
// and a execute property, the function implementation
const command = commands.find(c => c.data.name.toLowerCase() === interaction.commandName.toLowerCase());

if (command === undefined) {
    const noCommandEmbed = new EmbedBuilder({
        description: `${interaction.user}, cette commande n'existe pas !`,
        color: config.main.embedColor
    });

    interaction
        .editReply({ embeds: [noCommandEmbed] })
        .catch(console.error);
} else {
    command
        .execute(interaction)
        .catch(console.error);
}

I just make my own list beforehand

not get it from the guild.commands

vague totem

You shouldn't really need to do anything else besides registering the commands on that guild, you should still be receiving an interactionCreate event when someone uses the command on that guild. Im assuming you do have the Guilds intent enabled in your bot which is the minimum you need to receive this event