我正在为我的机器人添加一个烘焙小游戏。在这里,您可以按照机器人提供的不同说明来创建项目。
我想知道如何编辑我的机器人以前的消息以匹配其中一个步骤的进度。在这种情况下,您需要通过单击按钮将鸡蛋打入碗中。我正在努力做到这一点,以便每次您破解鸡蛋时机器人发送的消息都会更新您的进度,直到您达到配额。
var itemNames = args.join(' ').toLowerCase();
console.log(itemNames)
if ((itemNames === "cupcakes") || (itemNames === "cupcake")) {
const eggsButton = new MessageButton()
.setLabel("Crack Eggs!")
.setStyle("blurple")
.setID("cupcakesStepOne")
const cupcakesStepOne = await message.channel.send("Cupcakes, ok! Don't mess this up, dummy... We need to start with the eggs, why don't you crack a few into that bowl? **0 / 4**", eggsButton)
var eggs = 0
client.on('clickButton', async (button) => {
if (button.id === "cupcakesStepOne") {
button.reply.defer();
eggs = eggs + 1
console.log(eggs)
if (eggs = 1) {
cupcakesStepOne.edit("Cupcakes, ok! Don't mess this up, dummy... We need to start with the eggs, why don't you crack a few into that bowl? **1 / 4**")
} else {
if (eggs = 2) {
cupcakesStepOne.edit("Cupcakes, ok! Don't mess this up, dummy... We need to start with the eggs, why don't you crack a few into that bowl? **2 / 4**")
} else {
if (eggs = 3) {
cupcakesStepOne.edit("Cupcakes, ok! Don't mess this up, dummy... We need to start with the eggs, why don't you crack a few into that bowl? **3 / 4**")
} else {
if (eggs = 4) {
cupcakesStepOne.edit("Cupcakes, ok! Don't mess this up, dummy... We need to start with the eggs, why don't you crack a few into that bowl? **4 / 4**")
}
}
}
}
}
});
}
另外,如果我能更好地组织这个命令,请告诉我!我仍在学习 JavaScript,在这类东西方面我只是个业余爱好者。