Update id command from merge
All checks were successful
Deploy To Stage / build (push) Successful in 46s
Deploy To Stage / deploy (push) Successful in 18s

This commit is contained in:
Ethan Lane 2025-01-19 15:19:28 +00:00
parent 7213703f66
commit 3e81f8ce1d

View file

@ -43,22 +43,20 @@ export default class Id extends Command {
const series = CoreClient.Cards
.find(x => x.cards.includes(card))!;
let image: Buffer;
const imageFileName = card.path.split("/").pop()!;
const files = [];
let imageFileName = "";
try {
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
} catch {
AppLogger.LogError("Commands/View", `Unable to fetch image for card ${card.id}.`);
if (!(card.path.startsWith("http://") || card.path.startsWith("https://"))) {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
imageFileName = card.path.split("/").pop()!;
await interaction.reply(`Unable to fetch image for card ${card.id}.`);
return;
const attachment = new AttachmentBuilder(image, { name: imageFileName });
files.push(attachment);
}
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: imageFileName });
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
const quantityClaimed = inventory ? inventory.Quantity : 0;
@ -67,7 +65,7 @@ export default class Id extends Command {
try {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
});
} catch (e) {
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);