問題描述
我想將我的幫助命令從 djs v12.5.3 更新到 v13,但出現(xiàn)此錯誤:TypeError: message.client.commands.array is not a function
I wanted to update my help command from djs v12.5.3 to v13 but I got this error: TypeError: message.client.commands.array is not a function
這是我之前使用的代碼:
Here is my code I used before:
let commands = message.client.commands.array();
commands.forEach((cmd) => {
if(cmd.name == args[0].toLowerCase() || cmd.aliases.includes(args[0].toLowerCase())) {
embed.addField("**Description**", `${cmd.description}`, false)
embed.addField("**Usage**", `${cmd.usage}`, true)
embed.addField("**Aliases**", `${cmd.alias}`, true)
embed.addField("**Examples**", `${cmd.examples}`, true)
message.channel.send({ embeds: [embed] });
}
})
我嘗試將 let commands = message.client.commands.array();
更改為 let commands = message.client.commands.values();
但得到了另一個錯誤:TypeError: commands.forEach 不是函數(shù)
!如何在 v13 上再次列出我的命令?
I tried changing let commands = message.client.commands.array();
to let commands = message.client.commands.values();
but got another error: TypeError: commands.forEach is not a function
!
How can I list my commands again on v13?
推薦答案
該功能已被刪除.您需要執(zhí)行以下操作,而不是 .array
:
That function was removed. Instead of .array
, you need to do the following:
let commands = [...message.client.commands.values()]
但是沒有理由轉(zhuǎn)換,除非您想輕松顯示所有值.
However there is no reason to convert, unless you want to display all the values easily.
message.client.commands.each
可以正常工作
message.client.commands.each((cmd) => {})
這篇關(guān)于TypeError:message.client.commands.array 不是函數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!