有人能帮我做args吗?我已经测试过.bet (number under 99)了,但是它不会回复我的消息,而且和.bet (number more than 100)一样
//My code
if (message.content.startsWith(".bet")) {
let bet = args.join(" ");
// let bet = args[1]
if (!args[0]) {
return message.channel.send(`Woops, looks like you forgot to specify an amount to bet`)
}这就是问题所在
//the problems
if (args[1] <= 99) {
return
message.channel.send("Sorry, You cannot bet under 99$")
}
if (args[2] >= 100) {
return
await db.add(`user.money_${message.author.id}`, -bet)
message.channel.send("test")
}
//
}发布于 2022-01-27 08:15:42
您在文章中添加的代码片段没有显示定义args变量的部分,因此我在这里创建了一个。
const args = message.content.slice(".".length).trim().split(/ +/g).shift(); // split the message content on space and return the arguments
if (message.content.startsWith(".bet")) {
if (!args[0]) { // if there's no argument
return message.reply("Woops, looks like you forgot to specify an amount to bet!");
}
if (args[0] <= 99) { // if bet is equal/less than 99
return message.reply("Sorry, you cannot bet under $99.");
}
if (args[0] >= 100) { // if bet is equal/greater than 100
await db.add(`user.money_${message.author.id}`, -args[0]);
return message.reply("Successfully added a bet.");
}
}https://stackoverflow.com/questions/70873655
复制相似问题