diff --git a/.env.example b/.env.example index ef2c218..3ff53e9 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.5.2 +BOT_VER=0.5.0 BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=682942374040961060 diff --git a/.gitignore b/.gitignore index a9ed469..aecb458 100644 --- a/.gitignore +++ b/.gitignore @@ -108,5 +108,4 @@ config.json ormconfig.json gdrive-credentials.json data/ -.temp/ *.db \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1b9c8e7..e93e59f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "card-drop", - "version": "0.5.2", + "version": "0.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "card-drop", - "version": "0.5.2", + "version": "0.5.1", "license": "MIT", "dependencies": { "@discordjs/rest": "^2.0.0", diff --git a/package.json b/package.json index b64eec3..178f288 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "card-drop", - "version": "0.5.2", + "version": "0.5.1", "main": "./dist/bot.js", "typings": "./dist", "scripts": { diff --git a/src/buttonEvents/Claim.ts b/src/buttonEvents/Claim.ts index 3450dc4..6c45900 100644 --- a/src/buttonEvents/Claim.ts +++ b/src/buttonEvents/Claim.ts @@ -1,17 +1,17 @@ -import { ButtonInteraction } from "discord.js"; +import { AttachmentBuilder, ButtonInteraction } from "discord.js"; import { ButtonEvent } from "../type/buttonEvent"; import Inventory from "../database/entities/app/Inventory"; import { CoreClient } from "../client/client"; import { default as eClaim } from "../database/entities/app/Claim"; import AppLogger from "../client/appLogger"; import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata"; +import { readFileSync } from "fs"; +import path from "path"; export default class Claim extends ButtonEvent { public override async execute(interaction: ButtonInteraction) { if (!interaction.guild || !interaction.guildId) return; - await interaction.deferUpdate(); - const cardNumber = interaction.customId.split(" ")[1]; const claimId = interaction.customId.split(" ")[2]; const droppedBy = interaction.customId.split(" ")[3]; @@ -52,13 +52,17 @@ export default class Claim extends ButtonEvent { return; } + const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path)); const imageFileName = card.card.path.split("/").pop()!; + const attachment = new AttachmentBuilder(image, { name: imageFileName }); + const embed = CardDropHelperMetadata.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username); const row = CardDropHelperMetadata.GenerateDropButtons(card, claimId, interaction.user.id, true); - await interaction.editReply({ + await interaction.update({ embeds: [ embed ], + files: [ attachment ], components: [ row ], }); }