Update id command from merge
This commit is contained in:
parent
7213703f66
commit
3e81f8ce1d
1 changed files with 9 additions and 11 deletions
|
@ -43,22 +43,20 @@ export default class Id extends Command {
|
||||||
const series = CoreClient.Cards
|
const series = CoreClient.Cards
|
||||||
.find(x => x.cards.includes(card))!;
|
.find(x => x.cards.includes(card))!;
|
||||||
|
|
||||||
let image: Buffer;
|
const files = [];
|
||||||
const imageFileName = card.path.split("/").pop()!;
|
let imageFileName = "";
|
||||||
|
|
||||||
try {
|
if (!(card.path.startsWith("http://") || card.path.startsWith("https://"))) {
|
||||||
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
||||||
} catch {
|
imageFileName = card.path.split("/").pop()!;
|
||||||
AppLogger.LogError("Commands/View", `Unable to fetch image for card ${card.id}.`);
|
|
||||||
|
|
||||||
await interaction.reply(`Unable to fetch image for card ${card.id}.`);
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
return;
|
|
||||||
|
files.push(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ export default class Id extends Command {
|
||||||
try {
|
try {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: [ attachment ],
|
files: files,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);
|
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);
|
||||||
|
|
Loading…
Reference in a new issue