简体   繁体   English

如何从 discord.js 客户端删除斜杠命令

[英]How do i delete a slash command from discord.js client

I added two slash commands accidently and I tried to delete it but it requires ID and I couldn't get Id of an client command我不小心添加了两个斜杠命令,我试图删除它,但它需要 ID,我无法获取客户端命令的 ID

i think something like this solution would work for you: https://stackoverflow.com/a/69171716/13269697我认为这样的解决方案适合你: https://stackoverflow.com/a/69171716/13269697

guild.commands.delete('123456789012345678')

and you get your command id via something like this in the replies:并且您通过回复中的类似内容获得您的命令 ID:

guild.commands.cache.forEach((value, key) => { 
  // key is then your id or do value.id
  console.log(value.id)
}) 

ApplicationCommandManager 应用命令管理器

also, make sure you did remove the duplicate in your code if you didn't already or it'll just re-appear the next time you push commands另外,如果您还没有删除代码中的重复项,请确保您确实删除了重复项,否则它会在您下次推送命令时重新出现

edit:编辑:

you could just reset all of the commands and then repush them if that's easier.如果这更容易,您可以重置所有命令,然后重新推送它们。 then remove this line so it doesn't always reset.然后删除此行,这样它就不会总是重置。

client.application.commands.set([])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM