Fix some shit, Note to self: Dont code while tired
This commit is contained in:
parent
eae8bcd6ff
commit
df07ce2940
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -129,11 +129,11 @@ dist
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
config.json
|
|
||||||
config.json.old
|
|
||||||
config.json.disabled
|
|
||||||
.ssh/*
|
.ssh/*
|
||||||
!.ssh/.gitkeep
|
!.ssh/.gitkeep
|
||||||
testing/
|
testing/
|
||||||
levels.db
|
levels.db
|
||||||
database.db
|
database.db
|
||||||
|
config.json
|
||||||
|
config.json.*
|
||||||
|
!config.json.disabled
|
56
index.js
56
index.js
|
@ -20,7 +20,6 @@ const db = new sqlite3.Database("./database.db");
|
||||||
|
|
||||||
// Create table if it doesn't exist
|
// Create table if it doesn't exist
|
||||||
db.run("CREATE TABLE IF NOT EXISTS points (id TEXT, points INTEGER)");
|
db.run("CREATE TABLE IF NOT EXISTS points (id TEXT, points INTEGER)");
|
||||||
// update table if it does exist
|
|
||||||
|
|
||||||
client.on("ready", async () => {
|
client.on("ready", async () => {
|
||||||
console.log(`${colors.cyan("[INFO]")} Logged in as ${colors.green(client.user.tag)}`)
|
console.log(`${colors.cyan("[INFO]")} Logged in as ${colors.green(client.user.tag)}`)
|
||||||
|
@ -95,14 +94,9 @@ client.on("interactionCreate", async interaction => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
switch (interaction.commandName) {
|
switch (interaction.commandName) {
|
||||||
case "coins":
|
case "coins":
|
||||||
var user;
|
|
||||||
if (interaction.options.getMember("user")) {
|
|
||||||
user = interaction.options.getMember("user").user;
|
|
||||||
} else {
|
|
||||||
user = interaction.user;
|
|
||||||
}
|
|
||||||
// Get user data
|
// Get user data
|
||||||
balance = await checkPoints(interaction.user);
|
user = interaction.options.getUser("user") || interaction.user;
|
||||||
|
balance = await checkPoints(interaction.options.getUser("user") || interaction.user);
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: `${user.username}'s Coins`,
|
title: `${user.username}'s Coins`,
|
||||||
|
@ -460,6 +454,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
slotCooldowns[interaction.user.id] = Date.now() + (config.games.slots.cooldown * 60 * 1000);
|
||||||
|
|
||||||
// Check if they have enough money to play, 3 coins, if they do take it and continue
|
// Check if they have enough money to play, 3 coins, if they do take it and continue
|
||||||
balance = await checkPoints(interaction.user);
|
balance = await checkPoints(interaction.user);
|
||||||
|
@ -467,7 +462,6 @@ client.on("interactionCreate", async interaction => {
|
||||||
content: "You do not have enough coins to play slots.",
|
content: "You do not have enough coins to play slots.",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
checkAndModifyPoints(interaction.user, -3);
|
|
||||||
|
|
||||||
// Get the slot results, yes it's pre-defined, but it's not like it matters
|
// Get the slot results, yes it's pre-defined, but it's not like it matters
|
||||||
let slotResults = playSlotMachine();
|
let slotResults = playSlotMachine();
|
||||||
|
@ -475,16 +469,21 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${config.games.slots.spinning}${config.games.slots.spinning}${config.games.slots.spinning}`,
|
description: `[${config.games.slots.spinning}][${config.games.slots.spinning}][${config.games.slots.spinning}]`,
|
||||||
color: 0xffff00
|
color: 0xffff00
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check if they won or lost, if they won, give them the prize
|
||||||
|
difference = await new Number(slotResults.coinDifference);
|
||||||
|
// If they lost subtract 3 coins from the difference
|
||||||
|
if (difference <= 0) difference -= 3;
|
||||||
// Wait 4 seconds, then one at a time change the slots, 1 second apart
|
// Wait 4 seconds, then one at a time change the slots, 1 second apart
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${slotResults.spinResult[0]}${config.games.slots.spinning}${config.games.slots.spinning}`,
|
description: `[${slotResults.spinResult[0]}][${config.games.slots.spinning}][${config.games.slots.spinning}]`,
|
||||||
color: 0xffff00
|
color: 0xffff00
|
||||||
}]
|
}]
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -492,7 +491,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${config.games.slots.spinning}`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${config.games.slots.spinning}]`,
|
||||||
color: 0xffff00
|
color: 0xffff00
|
||||||
}]
|
}]
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -500,20 +499,16 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]}`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}]`,
|
||||||
color: 0xffff00
|
color: 0xffff00
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
// Check if they won or lost, if they won, give them the prize
|
|
||||||
difference = await new Number(slotResults.coinDifference);
|
|
||||||
await checkAndModifyPoints(interaction.user, difference);
|
|
||||||
if (difference > 0) {
|
if (difference > 0) {
|
||||||
await checkAndModifyPoints(interaction.user, 3);
|
|
||||||
if (slotResults.jackpot) {
|
if (slotResults.jackpot) {
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Jackpot!",
|
title: "Jackpot!",
|
||||||
description: `:rotating_light: ${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]} :rotating_light:\nYou won the jackpot! (${difference} coins)`,
|
description: `:rotating_light: [${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}] :rotating_light:\nYou won the jackpot! (${difference} coins)`,
|
||||||
color: 0xffffff
|
color: 0xffffff
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -521,7 +516,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Triple!",
|
title: "Triple!",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]}\nYou won ${difference + 3} coins! (You get your play fee back)`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}]\nYou won ${difference} coins!`,
|
||||||
color: 0x00ffff
|
color: 0x00ffff
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -529,7 +524,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]}\nYou won ${difference + 3} coins! (You get your play fee back)`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}]\nYou won ${difference} coins! (You get your play fee back)`,
|
||||||
color: 0x00ff00
|
color: 0x00ff00
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -541,7 +536,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Bombs!",
|
title: "Bombs!",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]}\nYou lost ${Math.abs(difference - 3)} coins!`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}]\nYou lost ${Math.abs(difference)} coins!`,
|
||||||
color: 0xff0000
|
color: 0xff0000
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -549,14 +544,13 @@ client.on("interactionCreate", async interaction => {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Slots",
|
title: "Slots",
|
||||||
description: `${slotResults.spinResult[0]}${slotResults.spinResult[1]}${slotResults.spinResult[2]}\nYou lost ${Math.abs(difference - 3)} coins!`,
|
description: `[${slotResults.spinResult[0]}][${slotResults.spinResult[1]}][${slotResults.spinResult[2]}]\nYou lost ${Math.abs(difference)} coins!`,
|
||||||
color: 0xff0000
|
color: 0xff0000
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set the cooldown for slots
|
await checkAndModifyPoints(interaction.user, difference);
|
||||||
slotCooldowns[interaction.user.id] = Date.now() + (config.games.slots.cooldown * 60 * 1000);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
@ -601,7 +595,7 @@ client.on("interactionCreate", async interaction => {
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: "Coinflip",
|
title: "Coinflip",
|
||||||
description: `You flipped ${coin ? config.games.coinflip.heads : config.games.coinflip.tails} and **${coin ? "won" : "lost"}** ${Math.abs(bet)} coins!\nYou now have ${before + bet} coins.`,
|
description: `You flipped ${coin ? config.games.coinflip.heads : config.games.coinflip.tails} and **${coin ? "won" : "lost"}** ${Math.abs(bet)} coins!`,
|
||||||
color: coin ? 0x00ff00 : 0xff0000
|
color: coin ? 0x00ff00 : 0xff0000
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -756,15 +750,15 @@ function playSlotMachine() {
|
||||||
let jackpot = false;
|
let jackpot = false;
|
||||||
let bombs = false;
|
let bombs = false;
|
||||||
if (iconCounts['🍎'] === 2) {
|
if (iconCounts['🍎'] === 2) {
|
||||||
coinDifference = 3;
|
coinDifference = 1;
|
||||||
} else if (iconCounts['🍎'] === 3) {
|
} else if (iconCounts['🍎'] === 3) {
|
||||||
triple = true;
|
triple = true;
|
||||||
coinDifference = 5;
|
coinDifference = 2;
|
||||||
} else if (iconCounts['🍋'] === 2) {
|
} else if (iconCounts['🍋'] === 2) {
|
||||||
coinDifference = 4;
|
coinDifference = 3;
|
||||||
} else if (iconCounts['🍋'] === 3) {
|
} else if (iconCounts['🍋'] === 3) {
|
||||||
triple = true;
|
triple = true;
|
||||||
coinDifference = 6;
|
coinDifference = 5;
|
||||||
} else if (iconCounts['🍒'] === 2) {
|
} else if (iconCounts['🍒'] === 2) {
|
||||||
coinDifference = 5;
|
coinDifference = 5;
|
||||||
} else if (iconCounts['🍒'] === 3) {
|
} else if (iconCounts['🍒'] === 3) {
|
||||||
|
@ -776,7 +770,7 @@ function playSlotMachine() {
|
||||||
triple = true;
|
triple = true;
|
||||||
coinDifference = 9;
|
coinDifference = 9;
|
||||||
} else if (iconCounts['⭐'] === 2) {
|
} else if (iconCounts['⭐'] === 2) {
|
||||||
coinDifference = 8;
|
coinDifference = 9;
|
||||||
} else if (iconCounts['⭐'] === 3) {
|
} else if (iconCounts['⭐'] === 3) {
|
||||||
triple = true;
|
triple = true;
|
||||||
coinDifference = 12;
|
coinDifference = 12;
|
||||||
|
@ -784,7 +778,7 @@ function playSlotMachine() {
|
||||||
coinDifference = 9;
|
coinDifference = 9;
|
||||||
} else if (iconCounts['🌵'] === 3) {
|
} else if (iconCounts['🌵'] === 3) {
|
||||||
jackpot = true;
|
jackpot = true;
|
||||||
coinDifference = 17;
|
coinDifference = 12;
|
||||||
} else if (iconCounts['💣'] === 2) {
|
} else if (iconCounts['💣'] === 2) {
|
||||||
bombs = true;
|
bombs = true;
|
||||||
coinDifference = -7;
|
coinDifference = -7;
|
||||||
|
|
Loading…
Reference in a new issue