26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
const { ContextMenuCommandBuilder, ApplicationCommandType, StickerFormatType } = require("discord.js");
|
|
const fs = require('fs/promises');
|
|
|
|
module.exports = {
|
|
data : new ContextMenuCommandBuilder()
|
|
.setName("Sticker Log")
|
|
.setType(ApplicationCommandType.Message),
|
|
async execute(interaction) {
|
|
await interaction.deferReply();
|
|
|
|
const sticker = interaction.targetMessage.stickers.first();
|
|
if (!sticker) {
|
|
await interaction.editReply("This message does not contain a sticker.");
|
|
return;
|
|
}
|
|
const link = sticker.url;
|
|
const copyname = sticker.name + "_FE";
|
|
const response = await fetch(link);
|
|
const extension = (sticker.format == StickerFormatType.PNG) ? ".png" :
|
|
(sticker.format == StickerFormatType.APNG) ? ".apng" :
|
|
(sticker.format == StickerFormatType.LOTTIE) ? ".json" : ".webp";
|
|
// save the file
|
|
await fs.writeFile(`./stickers/${copyname}${extension}`, response.body);
|
|
await interaction.editReply(`Dowloaded ${sticker.name}!\n`);
|
|
}
|
|
} |