Fix bug where large file attachments would cause claiming to fail interaction
All checks were successful
Test / build (push) Successful in 2m28s
All checks were successful
Test / build (push) Successful in 2m28s
This commit is contained in:
parent
c6d78cc370
commit
297e34e1cf
2 changed files with 5 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -108,4 +108,5 @@ config.json
|
||||||
ormconfig.json
|
ormconfig.json
|
||||||
gdrive-credentials.json
|
gdrive-credentials.json
|
||||||
data/
|
data/
|
||||||
|
.temp/
|
||||||
*.db
|
*.db
|
|
@ -1,17 +1,17 @@
|
||||||
import { AttachmentBuilder, ButtonInteraction } from "discord.js";
|
import { ButtonInteraction } from "discord.js";
|
||||||
import { ButtonEvent } from "../type/buttonEvent";
|
import { ButtonEvent } from "../type/buttonEvent";
|
||||||
import Inventory from "../database/entities/app/Inventory";
|
import Inventory from "../database/entities/app/Inventory";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import { default as eClaim } from "../database/entities/app/Claim";
|
import { default as eClaim } from "../database/entities/app/Claim";
|
||||||
import AppLogger from "../client/appLogger";
|
import AppLogger from "../client/appLogger";
|
||||||
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
||||||
import { readFileSync } from "fs";
|
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
export default class Claim extends ButtonEvent {
|
export default class Claim extends ButtonEvent {
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
public override async execute(interaction: ButtonInteraction) {
|
||||||
if (!interaction.guild || !interaction.guildId) return;
|
if (!interaction.guild || !interaction.guildId) return;
|
||||||
|
|
||||||
|
await interaction.deferUpdate();
|
||||||
|
|
||||||
const cardNumber = interaction.customId.split(" ")[1];
|
const cardNumber = interaction.customId.split(" ")[1];
|
||||||
const claimId = interaction.customId.split(" ")[2];
|
const claimId = interaction.customId.split(" ")[2];
|
||||||
const droppedBy = interaction.customId.split(" ")[3];
|
const droppedBy = interaction.customId.split(" ")[3];
|
||||||
|
@ -52,17 +52,13 @@ export default class Claim extends ButtonEvent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
|
||||||
const imageFileName = card.card.path.split("/").pop()!;
|
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 embed = CardDropHelperMetadata.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username);
|
||||||
const row = CardDropHelperMetadata.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
const row = CardDropHelperMetadata.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
||||||
|
|
||||||
await interaction.update({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: [ attachment ],
|
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue