【发布时间】:2021-09-02 09:46:20
【问题描述】:
所以我正在尝试使用 discord.js 开发一个不和谐机器人,并且我想制作一个记分牌,但由于某种原因,当调用向记分牌添加点的命令时,我无法更改变量.有人可以帮忙吗?分数始终保持在 0。另外,我是编程的初学者,所以如果您能以简单易懂的方式解释,将不胜感激。谢谢!
client.on('message', msg => {
var x = 0
var y = 0
if(msg.content.toLowerCase() === 'r!score x 1') {
x = x + 1;
msg.channel.send("Team y has won a point, now they're at " + x + "!")
}else if(msg.content.toLowerCase() === 'r!score y 1') {
y = y + 1;
msg.channel.send("Team y has won a point, now they're at " + y + "!")
} else if(msg.content.toLowerCase() === 'r!placar') {
const scoreboard = new Discord.MessageEmbed()
.setColor("#0099ff")
.setTitle("**Scoreboard**")
.addFields(
{name: "__Team X__", value: x + " points"},
{name: "__Team Y__", value: y + " points"}
);
msg.channel.send(scoreboard)
}
})
【问题讨论】:
标签: javascript discord.js