Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

393
Views
Delete Discord.js v13 slash command that doesnt exist

lately, I started working on a discord bot and added slash commands.

I noticed that I have a ping(replies with pong) command that I didn't create or I did and I can't get rid of it.

Here is my interactionHandler.js

const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");

module.exports = async (err, files, client) => {
  if (err) return console.error(err);

  client.interactionsArray = [];
  files.forEach((file) => {
    const interaction = require(`./../interactions/${file}`);
    client.interactions.set(interaction.data.name, interaction);
    client.interactionsArray.push(interaction.data.toJSON());
  });

  const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_TOKEN);
  
  (async () => {
    try {
      // console.log("Refreshing slash command list");
      // const guildIds = await client.guilds.cache.map((guild) => guild.id);
      // const clientId = await client.user.id;
      // guildIds.forEach(async (guildId) => {
      //   await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
      //     body: client.interactionsArray,
      //   });
      // });
      await rest.put(
            Routes.applicationGuildCommands("934895917453168653", "967384688069066852"),
            { body: client.interactionsArray},
        );

      console.log("Successfully refreshed slash command list");
    } catch (error) {
      console.error(error);
    }
  })();
};

Is there a way to delete the command because I cant find a way. I was thinking of getting the ID of the command but I don't know how. Thanks for all the helpers :) Discord.js v13

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

These commands may not be refreshing because of 2 reasons:

  • These commands may be global commands to change that to refreshing global (instead of guild) commands replace Routes.applicationGuildCommands to Routes.applicationCommands
  • These commands may be from a different guild which in the case you should change the guild ID

To figure out the problem you should do client.application.commands.fetch() to get all your commands and then console.log() the result.

Example

//This will fetch all your slash commands
const commands = await client.application.commands.fetch();
//Returns a collection of application commands
console.log(commands);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!