diff --git a/src/buttonEvents/Claim.ts b/src/buttonEvents/Claim.ts index 190a09e..4d5d97a 100644 --- a/src/buttonEvents/Claim.ts +++ b/src/buttonEvents/Claim.ts @@ -58,7 +58,7 @@ export default class Claim extends ButtonEvent { if (!inventory) { inventory = new Inventory(userId, cardNumber, 1); } else { - inventory.AddQuantity(1); + inventory.SetQuantity(inventory.Quantity + 1); } await inventory.Save(Inventory, inventory); diff --git a/src/buttonEvents/Multidrop.ts b/src/buttonEvents/Multidrop.ts deleted file mode 100644 index 88bd240..0000000 --- a/src/buttonEvents/Multidrop.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { ButtonInteraction, EmbedBuilder } from "discord.js"; -import { ButtonEvent } from "../type/buttonEvent"; -import AppLogger from "../client/appLogger"; -import { CoreClient } from "../client/client"; -import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata"; -import Inventory from "../database/entities/app/Inventory"; -import EmbedColours from "../constants/EmbedColours"; -import { readFileSync } from "fs"; -import path from "path"; - -export default class Multidrop extends ButtonEvent { - public override async execute(interaction: ButtonInteraction) { - const action = interaction.customId.split(" ")[1]; - - switch (action) { - case "keep": - await this.Keep(interaction); - break; - default: - await interaction.reply("Invalid action"); - AppLogger.LogError("Button/Multidrop", `Invalid action, ${action}`); - } - } - - public async Keep(interaction: ButtonInteraction) { - const cardNumber = interaction.customId.split(" ")[2]; - let cardsRemaining = Number(interaction.customId.split(" ")[3]) || 0; - const userId = interaction.customId.split(" ")[4]; - - if (interaction.user.id != userId) { - await interaction.reply("You're not the user this drop was made for!"); - return; - } - - const card = CardDropHelperMetadata.GetCardByCardNumber(cardNumber); - - if (!card) { - await interaction.reply("Unable to find card."); - AppLogger.LogWarn("Button/Multidrop/Keep", `Card not found, ${cardNumber}`); - return; - } - - if (cardsRemaining < 0) { - await interaction.reply("Your multidrop has ran out! Please buy a new one!"); - return; - } - - // Claim - let inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, cardNumber); - - if (!inventory) { - inventory = new Inventory(interaction.user.id, cardNumber, 1); - } else { - inventory.AddQuantity(1); - } - - await inventory.Save(Inventory, inventory); - - // Pack has ran out - if (cardsRemaining == 0) { - const embed = new EmbedBuilder() - .setDescription("Your multidrop has ran out! Please buy a new one!") - .setColor(EmbedColours.Ok); - - await interaction.update({ embeds: [ embed ]}); - return; - } - - // Drop next card - cardsRemaining -= 1; - - await interaction.deferUpdate(); - - try { - const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", )) - } - } -} \ No newline at end of file diff --git a/src/commands/multidrop.ts b/src/commands/multidrop.ts index f35b921..77cd4b2 100644 --- a/src/commands/multidrop.ts +++ b/src/commands/multidrop.ts @@ -16,7 +16,7 @@ export default class Multidrop extends Command { super(); this.CommandBuilder = new SlashCommandBuilder() - .setName("multidrop") + .setName("mutlidrop") .setDescription("Drop 11 cards for the price of 10!"); } @@ -70,18 +70,6 @@ export default class Multidrop extends Command { const quantityClaimed = inventory ? inventory.Quantity : 0; const embed = CardDropHelperMetadata.GenerateMultidropEmbed(randomCard, quantityClaimed, imageFileName, cardsRemaining, undefined, user.Currency); - - const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id); - - await interaction.editReply({ - embeds: [ embed ], - files: [ attachment ], - components: [ row ], - }); - } catch (e) { - AppLogger.LogError("Commands/Multidrop", `Error sending next drop for card ${randomCard.card.id}: ${e}`); - - await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`); } } } \ No newline at end of file diff --git a/src/helpers/CardDropHelperMetadata.ts b/src/helpers/CardDropHelperMetadata.ts index 8b9b273..bc88c88 100644 --- a/src/helpers/CardDropHelperMetadata.ts +++ b/src/helpers/CardDropHelperMetadata.ts @@ -1,5 +1,5 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js"; -import { CardRarity, CardRarityToColour, CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity"; +import { CardRarity, CardRarityToColour, CardRarityToString } from "../constants/CardRarity"; import CardRarityChances from "../constants/CardRarityChances"; import { DropResult } from "../contracts/SeriesMetadata"; import { CoreClient } from "../client/client"; @@ -158,17 +158,16 @@ export default class CardDropHelperMetadata { return dropEmbed; } - public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, userId: string, disabled = false): ActionRowBuilder { + public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, disabled = false): ActionRowBuilder { return new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining} ${userId}`) + .setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining}`) .setLabel("Keep") .setStyle(ButtonStyle.Primary) .setDisabled(disabled), new ButtonBuilder() - .setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining} ${userId}`) - .setLabel(`Sacrifice (+${GetSacrificeAmount(drop.card.type)} 🪙)`) + .setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining}`) .setStyle(ButtonStyle.Secondary)); } } diff --git a/src/registry.ts b/src/registry.ts index 7b87777..67936c8 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -11,7 +11,6 @@ import Gdrivesync from "./commands/gdrivesync"; import Give from "./commands/give"; import Id from "./commands/id"; import Inventory from "./commands/inventory"; -import Multidrop from "./commands/multidrop"; import Resync from "./commands/resync"; import Sacrifice from "./commands/sacrifice"; import Series from "./commands/series"; @@ -47,7 +46,6 @@ export default class Registry { CoreClient.RegisterCommand("give", new Give()); CoreClient.RegisterCommand("id", new Id()); CoreClient.RegisterCommand("inventory", new Inventory()); - CoreClient.RegisterCommand("multidrop", new Multidrop()); CoreClient.RegisterCommand("resync", new Resync()); CoreClient.RegisterCommand("sacrifice", new Sacrifice()); CoreClient.RegisterCommand("series", new Series());