converted ShaiBot casino to Nut Economy
This commit is contained in:
+240
@@ -0,0 +1,240 @@
|
||||
const {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
MessageFlags
|
||||
} = require("discord.js");
|
||||
|
||||
const {
|
||||
getNutBalance
|
||||
} = require("./nutEconomy");
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* SHOW HUB
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
async function showNutHub(
|
||||
interaction
|
||||
) {
|
||||
const balance =
|
||||
await getNutBalance(
|
||||
interaction.user.id
|
||||
);
|
||||
|
||||
|
||||
const embed =
|
||||
buildNutHubEmbed(
|
||||
interaction.user,
|
||||
balance
|
||||
);
|
||||
|
||||
|
||||
const components =
|
||||
buildNutHubButtons();
|
||||
|
||||
|
||||
/*
|
||||
* Slash command / fresh interaction.
|
||||
*/
|
||||
|
||||
if (
|
||||
!interaction.replied &&
|
||||
!interaction.deferred
|
||||
) {
|
||||
return interaction.reply({
|
||||
embeds: [
|
||||
embed
|
||||
],
|
||||
|
||||
components
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Existing game/menu message.
|
||||
*/
|
||||
|
||||
return interaction.update({
|
||||
embeds: [
|
||||
embed
|
||||
],
|
||||
|
||||
components
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* EMBED
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildNutHubEmbed(
|
||||
user,
|
||||
balance
|
||||
) {
|
||||
return new EmbedBuilder()
|
||||
.setTitle(
|
||||
"🥜 Nut Hub"
|
||||
)
|
||||
|
||||
.setDescription(
|
||||
[
|
||||
`Willkommen, ${user}!`,
|
||||
"",
|
||||
"Hier werden Nüsse gewonnen, verloren und gelegentlich konfisziert.",
|
||||
"",
|
||||
"### 🎰 Nut Slots",
|
||||
"Dreh die Walzen und jag den Jackpot.",
|
||||
"",
|
||||
"### 🃏 Nut Blackjack",
|
||||
"Schlag den Dealer ohne über 21 zu kommen.",
|
||||
"",
|
||||
"### 🎡 Nut Roulette",
|
||||
"Setz auf Rot, Schwarz, Ungerade, Gerade oder Zero.",
|
||||
"",
|
||||
"### 🏦 Nut Heist",
|
||||
"Versuch dich direkt am Nut Vault des Bots.",
|
||||
"",
|
||||
"*Choose wisely. The house has very large nuts.*"
|
||||
].join("\n")
|
||||
)
|
||||
|
||||
.addFields({
|
||||
name:
|
||||
"Deine Nüsse",
|
||||
|
||||
value:
|
||||
`**${balance.toLocaleString()} 🥜**`
|
||||
})
|
||||
|
||||
.setThumbnail(
|
||||
user.displayAvatarURL({
|
||||
size:
|
||||
256
|
||||
})
|
||||
)
|
||||
|
||||
.setFooter({
|
||||
text:
|
||||
`nutHub:${user.id}`
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* BUTTONS
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function buildNutHubButtons() {
|
||||
return [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"nutHubSlots"
|
||||
)
|
||||
.setLabel(
|
||||
"Slots"
|
||||
)
|
||||
.setEmoji(
|
||||
"🎰"
|
||||
)
|
||||
.setStyle(
|
||||
ButtonStyle.Primary
|
||||
),
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"nutHubBlackjack"
|
||||
)
|
||||
.setLabel(
|
||||
"Blackjack"
|
||||
)
|
||||
.setEmoji(
|
||||
"🃏"
|
||||
)
|
||||
.setStyle(
|
||||
ButtonStyle.Success
|
||||
),
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"nutHubRoulette"
|
||||
)
|
||||
.setLabel(
|
||||
"Roulette"
|
||||
)
|
||||
.setEmoji(
|
||||
"🎡"
|
||||
)
|
||||
.setStyle(
|
||||
ButtonStyle.Primary
|
||||
),
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId(
|
||||
"nutHubHeist"
|
||||
)
|
||||
.setLabel(
|
||||
"Vault Heist"
|
||||
)
|
||||
.setEmoji(
|
||||
"🏦"
|
||||
)
|
||||
.setStyle(
|
||||
ButtonStyle.Danger
|
||||
)
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================
|
||||
* OWNERSHIP
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
function getNutHubOwner(
|
||||
interaction
|
||||
) {
|
||||
const footer =
|
||||
interaction.message
|
||||
?.embeds?.[0]
|
||||
?.footer
|
||||
?.text;
|
||||
|
||||
|
||||
const parts =
|
||||
footer?.split(":")
|
||||
??
|
||||
[];
|
||||
|
||||
|
||||
if (
|
||||
parts[0] !==
|
||||
"nutHub"
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return parts[1];
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
showNutHub,
|
||||
buildNutHubEmbed,
|
||||
buildNutHubButtons,
|
||||
getNutHubOwner
|
||||
};
|
||||
Reference in New Issue
Block a user