l1l1th/src/commands/fun/quote.js
2024-10-20 16:26:35 +02:00

38 lines
1.2 KiB
JavaScript

const { ContextMenuCommandBuilder, ApplicationCommandType, InteractionContextType, ApplicationIntegrationType, AttachmentBuilder } = require("discord.js");
const { createQuoteImage } = require("../../utils/quoter.js");
const data = new ContextMenuCommandBuilder()
.setName("Quote")
.setType(ApplicationCommandType.Message)
.setContexts([
InteractionContextType.Guild,
InteractionContextType.BotDM,
InteractionContextType.PrivateChannel
])
.setIntegrationTypes([
ApplicationIntegrationType.GuildInstall,
ApplicationIntegrationType.UserInstall
]);
module.exports = {
data,
async execute(interaction) {
await interaction.deferReply();
const msg = interaction.targetMessage;
const user = msg.author;
const avatar = `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png?size=1024`;
try {
const data = await createQuoteImage(avatar, user.displayName, msg.content, true, interaction.client.users.cache);
await interaction.followUp({
files: [{
attachment: data,
name: "quote.png"
}]
})
} catch (e) {
interaction.followUp(e.toString());
}
},
};