added bankruptcy
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
const {
|
||||
closeInteractionSession
|
||||
} = require("../../utils/interactionSession");
|
||||
|
||||
module.exports = {
|
||||
name: "sessionClose",
|
||||
|
||||
async execute(interaction) {
|
||||
return closeInteractionSession(interaction);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,91 @@
|
||||
const {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
MessageFlags
|
||||
} = require("discord.js");
|
||||
|
||||
const {
|
||||
declareBankruptcy
|
||||
} = require("../../utils/bankruptcy");
|
||||
|
||||
const {
|
||||
requireInteractionSession
|
||||
} = require("../../utils/interactionSession");
|
||||
|
||||
module.exports = {
|
||||
name: "crumbSaucerBankruptcy",
|
||||
|
||||
async execute(interaction) {
|
||||
const session = await requireInteractionSession(interaction);
|
||||
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await declareBankruptcy(interaction);
|
||||
|
||||
if (!result.ok) {
|
||||
if (result.reason === "COOLDOWN") {
|
||||
return interaction.reply({
|
||||
content:
|
||||
`Bankruptcy assistance is unavailable until <t:${result.nextAvailableAt}:R>.`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
|
||||
if (result.reason === "BALANCE_NOT_ZERO") {
|
||||
return interaction.reply({
|
||||
content:
|
||||
`Bankruptcy can only be declared at exactly **0 Cookies**. Your current balance is **${result.balance.toLocaleString()}**.`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
|
||||
return interaction.reply({
|
||||
content: "Bankruptcy could not be declared.",
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle("🍪 Bankruptcy Assistance")
|
||||
.setDescription(
|
||||
[
|
||||
`${interaction.user} declared bankruptcy and received a starter kit.`,
|
||||
"",
|
||||
`**+${result.amount.toLocaleString()} Cookies**`,
|
||||
"",
|
||||
"Spend them wisely. Or at least memorably."
|
||||
].join("\n")
|
||||
)
|
||||
.addFields({
|
||||
name: "Next Eligibility",
|
||||
value: `<t:${result.nextAvailableAt}:R>`
|
||||
})
|
||||
.setFooter({
|
||||
text: `crumbSaucer:${interaction.user.id}`
|
||||
});
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("crumbSaucerBack")
|
||||
.setLabel("Back to Crumb Saucer")
|
||||
.setEmoji("◀️")
|
||||
.setStyle(ButtonStyle.Secondary),
|
||||
|
||||
new ButtonBuilder()
|
||||
.setCustomId("sessionClose")
|
||||
.setLabel("Close")
|
||||
.setEmoji("✖️")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
);
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components: [row]
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user