From 297e34e1cf45d8c8c0a735e50904f89f8a7d87a6 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 29 May 2024 17:36:58 +0100 Subject: [PATCH 1/3] Fix bug where large file attachments would cause claiming to fail interaction --- .gitignore | 1 + src/buttonEvents/Claim.ts | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index aecb458..a9ed469 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,5 @@ config.json ormconfig.json gdrive-credentials.json data/ +.temp/ *.db \ No newline at end of file diff --git a/src/buttonEvents/Claim.ts b/src/buttonEvents/Claim.ts index 6c45900..3450dc4 100644 --- a/src/buttonEvents/Claim.ts +++ b/src/buttonEvents/Claim.ts @@ -1,17 +1,17 @@ -import { AttachmentBuilder, ButtonInteraction } from "discord.js"; +import { 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,17 +52,13 @@ 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.update({ + await interaction.editReply({ embeds: [ embed ], - files: [ attachment ], components: [ row ], }); } From ba9ade0659644cec5098b5106d1a1282acc5c8c0 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 30 May 2024 17:28:43 +0100 Subject: [PATCH 2/3] 0.5.2 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 3ff53e9..ef2c218 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.5.0 +BOT_VER=0.5.2 BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=682942374040961060 From 34ea1f87d7bb199367f56f76b19144f19c1628ab Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 30 May 2024 17:34:22 +0100 Subject: [PATCH 3/3] 0.5.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e93e59f..1b9c8e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "card-drop", - "version": "0.5.1", + "version": "0.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "card-drop", - "version": "0.5.1", + "version": "0.5.2", "license": "MIT", "dependencies": { "@discordjs/rest": "^2.0.0", diff --git a/package.json b/package.json index 178f288..b64eec3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "card-drop", - "version": "0.5.1", + "version": "0.5.2", "main": "./dist/bot.js", "typings": "./dist", "scripts": {