case "coin":
if (args[1] === "heads", "tails") {
message.channel.sendMessage(`Your bet: ${args[1]}, outcome: ${coins[Math.floor(Math.random() * coins.length)]}`);
} else {
message.channel.sendMessage('Your arguments must include of sr!coin heads or sr!coin tails!');
}
它输出没有错误只接受除头尾之外的其他参数
答案 0 :(得分:0)
此声明if (args[1] === "heads", "tails"){...}
无法按照您的意愿执行。
我认为你在寻找:
if (args[1] === "heads" || args[1] === "tails"){....}
答案 1 :(得分:0)
什么是args
?是process.argv.slice(2)
吗?如果是,请执行:
if (['heads','tails'].includes(args[1]))