[英]Delete Discord.js v13 slash command that doesnt exist
lately, I started working on a discord bot and added slash commands.最近,我开始研究 discord 机器人并添加了斜杠命令。
Here is my interactionHandler.js这是我的 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.
我正在考虑获取命令的 ID,但我不知道如何获取。 Thanks for all the helpers:) Discord.js v13
感谢所有帮助者:) Discord.js v13
These commands may not be refreshing because of 2 reasons:由于 2 个原因,这些命令可能不会刷新:
Routes.applicationGuildCommands
to Routes.applicationCommands
Routes.applicationGuildCommands
替换为Routes.applicationCommands
To figure out the problem you should do client.application.commands.fetch()
to get all your commands and then console.log()
the result.要找出问题,您应该执行
client.application.commands.fetch()
以获取所有命令,然后执行console.log()
结果。
//This will fetch all your slash commands
const commands = await client.application.commands.fetch();
//Returns a collection of application commands
console.log(commands);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.