This commit is contained in:
Ashley Graves 2024-10-11 21:08:19 +02:00
parent de3c094833
commit 2a84e74cda
6 changed files with 519 additions and 86 deletions

40
src/commands/fun/quote.js Normal file
View file

@ -0,0 +1,40 @@
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`;
console.log("Generating quote image");
try {
const data = await createQuoteImage(avatar, user.username, msg.content, true, interaction.client.users.cache);
console.log("Sending quote image");
await interaction.followUp({
files: [{
attachment: data,
name: "quote.png"
}]
})
} catch (e) {
interaction.followUp(e.toString());
}
},
};