Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

395
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda