#interactionCreate.js doesn't pick up guild commands
23 messages · Page 1 of 1 (latest)
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
i know it's line 14, just don't know how to declare that
No such thing as GuildCommandManager#get(). https://old.discordjs.dev/#/docs/discord.js/14.13.0/class/GuildApplicationCommandManager
Maybe you're looking for .cache.get() or .fetch() they use the command's ID, not name btw
But I personally just make a collection with command names mapped to the function that runs the command and use that to get the needed command.
is there still a guild command class tho? i was told i can have 100 guild commands, and 100 global ?
Wdym?
i was told i can have 100 guild commands, and 100 global ?
that's true IIRC
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
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
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