slash commands not registering

I made a bot with initially 3 commands, then added 3 commands later on, and the new 3 commands won't display anywhere. I ran the exact same bot but on a different account and all 6 commands appear fine. I tried using Routes.applicationGuildCommands using my server's ID instead of Routes.applicationCommands, it worked at first, but the initial 3 commands were duplicated so I kicked and reinvited the bot, and the new 3 commands are now nowhere to be seen.
5 Replies
d.js toolkit
d.js toolkit3mo 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 staff
souji
souji3mo ago
i mean... you kicked the bot, of course the guild commands are gone? not sure what you expected here you can either deploy commands globally, so they are available in any guilds that have the app or you can deploy them on a specific guild if you remove the app from the guild all its commands in the context of that specific guild are also gone if you add the app to the server again, you have to deploy the commands again
LEveLiQ
LEveLiQOP3mo ago
I don't get what you're trying to say by "deploy the commands again"
export const registerCommands = async (client: Client) => {
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN!);
try {
await rest.put(
Routes.applicationGuildCommands(client.user!.id, process.env.GUILD_ID!),
{ body: commands }
);
} catch (error) {
console.error(error);
}
};
export const registerCommands = async (client: Client) => {
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN!);
try {
await rest.put(
Routes.applicationGuildCommands(client.user!.id, process.env.GUILD_ID!),
{ body: commands }
);
} catch (error) {
console.error(error);
}
};
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
]
});

client.once('ready', async () => {
console.log(`Logged in as ${client.user?.tag}!`);
await registerCommands(client);
});

client.on('interactionCreate', async (interaction: Interaction) => {
if (!interaction.isCommand() && !interaction.isAutocomplete()) return;
await handleInteraction(interaction);
});

client.login(process.env.TOKEN);
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
]
});

client.once('ready', async () => {
console.log(`Logged in as ${client.user?.tag}!`);
await registerCommands(client);
});

client.on('interactionCreate', async (interaction: Interaction) => {
if (!interaction.isCommand() && !interaction.isAutocomplete()) return;
await handleInteraction(interaction);
});

client.login(process.env.TOKEN);
this is what i did just added commands.length and data.length like the one in guide Logged in as <bot name>! Started refreshing 6 application (/) commands. Successfully reloaded 6 application (/) commands. weird only 3 are visible
3v.
3v.3mo ago
restart your client
LEveLiQ
LEveLiQOP2mo ago
you mean the discord app, right? done it a thousand times yeah, and it starts appearing randomly and there are duplicates (3 app + 6 guild apparently?) which irritates me and the global command still hasn't got updated, it's been 3 days should i create a new app in dev portal? fixed by creating an entirely new app because discord being discord

Did you find this page helpful?