nyx/commands/Economy/bet.js

52 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]);
if ((await client.data.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;
await client.data.add(message.author.id, winamt);
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 **${
parseInt(await client.data.bal(message.author.id)) - amt
}**${client.currency}`
);
2021-06-12 12:53:51 +02:00
message.inlineReply(abc);
} else {
await client.data.rmv(message.author.id, amt);
const cba = new MessageEmbed()
.setColor("RED")
.setTimestamp()
.setTitle(`${message.author.username} loses a gamble game`)
2021-06-24 09:53:19 +02:00
.setDescription(
`You lost\n**${winamt}**${client.currency}\nYou now have **${
parseInt(await client.data.bal(message.author.id)) - amt
}**${client.currency}`
);
2021-06-12 12:53:51 +02:00
message.inlineReply(cba);
}
},
};