Client only deploys 3-4 slash commands

Hey, I have 7 slash commands that I want to deploy but I can't (it only deploys 3 or 4).
const { REST, Routes } = require("discord.js");
const fs = require("fs");
const clientId = "1111931372249022474";
const guildId = "980900531260248104";
module.exports = (client) => {
client.handleCommands = async (slashCommandFolders, path) => {
client.slashCommandArray = [];
for (folder of slashCommandFolders) {
const slashCommandFiles = fs
.readdirSync(`${path}/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of slashCommandFiles) {
const command = require(`../slashcommands/${folder}/${file}`);
client.slashCommandArray.push(command.data.toJSON());
client.slashcommands.set(command.data.name, command);
}

const rest = new REST().setToken(process.env.DISCORD_TOKEN);

(async () => {
try {
console.log(
`Started refreshing ${client.slashCommandArray.length} application (/) commands.`
);
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: client.slashCommandArray }
);
console.log(
`Successfully reloaded ${data.length} application (/) commands.`
);
} catch (error) {
console.error(error);
}
})();
}
};
};
const { REST, Routes } = require("discord.js");
const fs = require("fs");
const clientId = "1111931372249022474";
const guildId = "980900531260248104";
module.exports = (client) => {
client.handleCommands = async (slashCommandFolders, path) => {
client.slashCommandArray = [];
for (folder of slashCommandFolders) {
const slashCommandFiles = fs
.readdirSync(`${path}/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of slashCommandFiles) {
const command = require(`../slashcommands/${folder}/${file}`);
client.slashCommandArray.push(command.data.toJSON());
client.slashcommands.set(command.data.name, command);
}

const rest = new REST().setToken(process.env.DISCORD_TOKEN);

(async () => {
try {
console.log(
`Started refreshing ${client.slashCommandArray.length} application (/) commands.`
);
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: client.slashCommandArray }
);
console.log(
`Successfully reloaded ${data.length} application (/) commands.`
);
} catch (error) {
console.error(error);
}
})();
}
};
};
Should I wait for client to deploy more or what?
13 Replies
d.js toolkit
d.js toolkit•17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
Pooyan
PooyanOP•17mo ago
discord.js v14.11.0 node.js v16
treble/luna
treble/luna•17mo ago
You should not deploy your commands on every start Only when you add or edit them
Pooyan
PooyanOP•17mo ago
So I need to use client.application?.commands.create(<scommand.data>, <guild.id>) at the end of every slash command file or what? 💀
treble/luna
treble/luna•17mo ago
No
d.js docs
d.js docs•17mo ago
guide Creating Your Bot: Registering slash commands The command deployment script, to register your slash commands with Discord so they appear in the interface. read more
It's Manny
It's Manny•17mo ago
I've heard that commands that are the same as before don't count towards the rate limit
treble/luna
treble/luna•17mo ago
nope regardless the rest.put sends a single api request
It's Manny
It's Manny•17mo ago
While I do agree that it's unnecessary to call the API when there's no change. I think only updates count
It's Manny
It's Manny•17mo ago
Or well creating them, but not 100% sure on that
treble/luna
treble/luna•17mo ago
thats for guild.commands.set, which you do not use
It's Manny
It's Manny•17mo ago
Ah alright, fair
Pooyan
PooyanOP•17mo ago
Yeah this solved the problem thanks
Want results from more Discord servers?
Add your server