【发布时间】:2022-10-14 03:18:47
【问题描述】:
我尝试使用client.application.commands.set 发布斜杠命令,但它不起作用。
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
arrayOfSlashCommands.push(file);
client.application.commands.set(arrayOfSlashCommands.name, arrayOfSlashCommands)
});
【问题讨论】:
-
arrayOfSlashCommands.name是什么?因为对我来说它看起来像[].name,即undefined -
它是斜杠命令的名称。
-
console.log(arrayOfSlashCommands.name)打印什么? -
它打印
undefined -
因为数组没有名为
name的属性。我猜你想把file.name放在这里。
标签: node.js discord.js