WIP: Card compositing

This commit is contained in:
2022-08-25 23:18:01 +02:00
parent 3f53e33598
commit 69cdc54c80
2 changed files with 92 additions and 26 deletions

37
commands/view.js Normal file
View File

@@ -0,0 +1,37 @@
const { SlashCommandBuilder, AttachmentBuilder } = require("discord.js");
const { Card, User, Character } = require("../models");
const Rendering = require("../util/rendering");
//fetch all cards owned by the user and list them
module.exports = {
data: new SlashCommandBuilder()
.setName("view")
.setDescription("View a specific card")
.addStringOption((option) =>
option
.setName("card")
.setDescription("Card identifier")
.setRequired(false)
),
async execute(interaction) {
await interaction.deferReply();
const cardId = interaction.options.getString('card');
const card = await Card.findOne({
where: {
identifier: cardId
},
include: [Character]
});
if (!card) {
interaction.reply({
content: "Card not found",
ephemeral: true
});
return;
}
let cardImage = await Rendering.renderCard(card);
const message = await interaction.editReply({ content: '', files: [new AttachmentBuilder(cardImage, { name: 'card.gif' })], fetchReply: true });
}
}