所以我创建了一个轮询命令,但是当我键入该命令时,每个单词之间都有逗号。
exports.run = async (bot, message, args) => {
let text = message.content.slice('__poll'.length);
if (!args) return message.reply("You must have something to vote for!")
message.channel.send(`:ballot_box: ${message.author.username} started a poll! React to my next message to vote on it. :ballot_box: `);
const pollTopic = await message.channel.send(`${args}`);
pollTopic.react(`✅`);
pollTopic.react(`⛔`);
};
当我希望问题出在哪里时,会发生这种情况
what,is,up!
答案 0 :(得分:1)
默认情况下,当将array转换为string时,JavaScript将用逗号分隔每个元素。要更改定界符,可以使用Array.join()
。
示例:
const arr = ['How', 'are', 'you?'];
console.log(`Original: ${arr}`);
const str = arr.join(' ');
console.log(`Joined: ${str}`);