This snippet will upload the sticker to your server. Reply the prefix command to a message that has a sticker. This will allow the bot to get the sticker from the message that you have replied to, and upload it to your server.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const REF_MESSAGE = context.params.event.referenced_message;
const stickers = REF_MESSAGE?.sticker_items;
if(!REF_MESSAGE){
return lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Hey <@!${context.params.event.author.id}>, reply to a message!`
});
}
await lib.discord.channels['@0.3.2'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`
});
try{
for(let sticker of stickers){
let buffer = await lib.http.request['@1.1.5']({
method: 'GET',
url: `https://media.discordapp.net/stickers/${sticker.id}.${sticker.format_type == 1? `png` : `webp`}`,
}).then((result) => {
return result.body;
});
await lib.discord.stickers['@0.0.0'].create({
guild_id: `${context.params.event.guild_id}`,
name: `${sticker.name}`,
file: buffer,
tags: `${sticker.name}`
});
}
}catch(e){
console.error(e);
return lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Error uploading sticker!\n${e.message}`,
message_reference: {
message_id: REF_MESSAGE.id
}
});
}
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Sticker successfully uploaded!`,
message_reference: {
message_id: REF_MESSAGE.id
}
});