This commit is contained in:
skkeye
2024-01-04 20:50:50 -05:00
parent e2f587994c
commit 7309779923
3 changed files with 28 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
config.json config.json
node_modules/ node_modules/
downloads/ downloads/
stickers/

View File

@@ -0,0 +1,26 @@
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`);
}
}

View File

@@ -3,7 +3,6 @@ const { Events } = require('discord.js');
module.exports = { module.exports = {
name: Events.InteractionCreate, name: Events.InteractionCreate,
async execute(interaction) { async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);