no command matching

Im trying to run my commands. already tried updating. latest version
6 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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 OP
Teun 火
Teun 火OP6mo ago
my index.js file is const fs = require('node:fs'); const path = require('node:path'); const { Client, Collection, Events, GatewayIntentBits, MessageFlags } = require('discord.js'); const { token } = require('./config.json'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.commands = new Collection(); const foldersPath = path.join(dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); if ('data' in command && 'execute' in command) { client.commands.set(command.data.name, command); } else { console.log([WARNING] The command at ${filePath} is missing a required "data" or "execute" property.); } } } client.once(Events.ClientReady, readyClient => { console.log(Ready! Logged in as ${readyClient.user.tag}); }); client.on(Events.InteractionCreate, async interaction => { if (!interaction.isChatInputCommand()) 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 this command!', flags: MessageFlags.Ephemeral }); } else { await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral }); } } }); client.login(token); . and my deploy commands is const { REST, Routes } = require('discord.js'); const { clientId, guildId, token } = require('./config.json'); const fs = require('node:fs'); const path = require('node:path'); const commands = []; // Grab all the command folders from the commands directory you created earlier const foldersPath = path.join(dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { // Grab all the command files from the commands directory you created earlier const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); if ('data' in command && 'execute' in command) { commands.push(command.data.toJSON()); } else { console.log([WARNING] The command at ${filePath} is missing a required "data" or "execute" property.); } } } // Construct and prepare an instance of the REST module const rest = new REST().setToken(token); // and deploy your commands! (async () => { try { console.log(Started refreshing ${commands.length} application (/) commands.); // The put method is used to fully refresh all commands in the guild with the current set const data = await rest.put( Routes.applicationCommands(clientId), { body: commands }, ); console.log(Successfully reloaded ${data.length} application (/) commands.); } catch (error) { // And of course, make sure you catch and log any errors! console.error(error); } })();
Teun 火
Teun 火OP6mo ago
No description
d.js docs
d.js docs6mo ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
treble/luna
treble/luna6mo ago
Also thats an error you made. Meaning you arent setting your commands properly
Teun 火
Teun 火OP6mo ago
i fixed it

Did you find this page helpful?