如果我将命令作为集合,如何将命令嵌入到页面中



我想将命令保存到页面中,比如每页5个命令。我不想自己写下嵌入中的所有命令。

有人知道我会怎么做吗?

您可以通过浏览您提到的命令列表来实现这一点,因为它们位于不同的文件中。。。

要获得所有可用命令的名称,您可以执行以下操作:

for (let file of commandFiles) {
let command = require(`./commands/${file}`);
console.log(command.name); // Print out the command name
}

但是,如果您想打印出所有命令,您可以将所有命令名附加到一个字符串中,字符串之间有一个换行符。

let commandNames;
for (let file of commandFiles) {
let command = require(`./commands/${file}`);
commandNames = commandNames + command.name + "n";
}

然后在嵌入中,您可以简单地在字段或描述中发送commandNames

你不应该需要对命令进行分页,除非你有很多命令,如果你真的想这样做,我建议研究一下这里的Message对象上的.createReactionCollector方法

最新更新