nyx/commands/Economy/bet.js

53 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "gamble",
aliases: ["bet"],
usage: "(Number)",
timeout: 5000,
description: "Win double amount of coins or lose all coins",
category: "Economy",
run: async (client, message, args) => {
const max = 1000000;
if (!args[0]) {
2021-06-24 09:53:19 +02:00
return client.err(message, "Economy", "bet", 5);
2021-06-12 12:53:51 +02:00
}
if (isNaN(args[0])) {
2021-06-24 09:53:19 +02:00
return client.err(message, "Economy", "bet", 7);
2021-06-12 12:53:51 +02:00
}
const amt = parseInt(args[0]);
2021-07-13 05:17:39 +02:00
if ((await client.bal(message.author.id)) < amt) {
2021-06-24 09:53:19 +02:00
return client.err(message, "Economy", "bet", 20);
2021-06-12 12:53:51 +02:00
}
if (amt > max) {
2021-06-24 09:53:19 +02:00
return client.err(message, "Economy", "bet", 101);
2021-06-12 12:53:51 +02:00
}
if (client.function.random() === true) {
const winamt = amt * 1;
2021-07-13 05:17:39 +02:00
await client.add(message.author.id, winamt, message);
await client.ADDBWin(message.author.id);
2021-06-12 12:53:51 +02:00
const abc = new MessageEmbed()
.setColor("GREEN")
.setTimestamp()
.setTitle(`${message.author.username} wins a gamble game`)
2021-06-24 09:53:19 +02:00
.setDescription(
`You win\n**${winamt}**${client.currency}\nYou now have **${
2021-07-13 05:17:39 +02:00
parseInt(await client.bal(message.author.id)) - amt
2021-06-24 09:53:19 +02:00
}**${client.currency}`
);
2021-09-06 12:38:25 +02:00
message.reply(abc);
2021-06-12 12:53:51 +02:00
} else {
2021-07-13 05:17:39 +02:00
await client.rmv(message.author.id, amt);
2021-06-12 12:53:51 +02:00
const cba = new MessageEmbed()
.setColor("RED")
.setTimestamp()
.setTitle(`${message.author.username} loses a gamble game`)
2021-06-24 09:53:19 +02:00
.setDescription(
2021-07-13 05:17:39 +02:00
`You lost\n**${amt}**${client.currency}\nYou now have **${
parseInt(await client.bal(message.author.id)) - amt
2021-06-24 09:53:19 +02:00
}**${client.currency}`
);
2021-09-06 12:38:25 +02:00
message.reply(cba);
2021-06-12 12:53:51 +02:00
}
},
};