【发布时间】:2017-12-29 06:00:25
【问题描述】:
所以我正在创建一个不和谐的机器人,我希望它滚动一个随机数(我已经知道如何做到这一点),如果滚动高于 49,用户可以使用命令“购买”。现在这是我无法编码的部分。如何将特定命令附加到条件。此外,如果玩家低于 49,他将无法使用“购买”。
if(command === "shekels"){
var object = (prizes[Math.floor(Math.random()*prizes.length)])
var shekels = Math.floor(Math.random()*99 +1 )
message.channel.send(`You rolled ${shekels} shekels !`)
if(shekels <49){
message.channel.send("Oi you dont have enough shekels to buy at my store *rubs hands*")
}//49 brackets
else{
message.channel.send("Hey you do have enough shekels to buy something from my store")
};
};//command bracket
if(shekels < 49){
message.channel.send("Oi you dont have enough shekels to buy at my store *rubs hands*");
}//49 brackets
else{
allowedUsers.push(message.author.username);
};
if(command === "buy"){
if(!allowedUsers.includes(message.author.username)){
return message.channel.send("You did not roll 49 or above so you cannot use this command.");
}
else{
message.channel.send("here " + objectStore);
};
};
上面的命令 ^ 对我不起作用
【问题讨论】:
-
所以当这个人超过 49 岁后,他可以输入另一个命令,让他买东西,如果他没有得到它,他将无法执行该命令
标签: javascript node.js visual-studio discord