你如何在 discord.js 中使用多个单词的参数?
How do you use arguments with multiple words in discord.js?
如何在 discord.js 中获取包含多个单词的参数?
如在
!alert <content [multiple words]>
因为目前我的代码将我的命令作为
!alert content1[0] content2[1] and so on
所以基本上,你如何才能使这些参数成为一个字符串。
谢谢
编辑:这是我的论点拆分器:
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
您的论点很可能是 Array
. You can use Array.join()
。
const args = ["content1", "content2"];
console.log("BEFORE JOIN \/")
console.log(args)
console.log(args[0])
console.log(args[1])
console.log("BEFORE JOIN /\")
console.log("AFTER JOIN \/")
console.log(args.join(" "))
console.log("AFTER JOIN /\")
如何在 discord.js 中获取包含多个单词的参数?
如在
!alert <content [multiple words]>
因为目前我的代码将我的命令作为
!alert content1[0] content2[1] and so on
所以基本上,你如何才能使这些参数成为一个字符串。
谢谢
编辑:这是我的论点拆分器:
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
您的论点很可能是 Array
. You can use Array.join()
。
const args = ["content1", "content2"];
console.log("BEFORE JOIN \/")
console.log(args)
console.log(args[0])
console.log(args[1])
console.log("BEFORE JOIN /\")
console.log("AFTER JOIN \/")
console.log(args.join(" "))
console.log("AFTER JOIN /\")