This snippet makes a fake Instagram post with a lot of likes .... {prefix}post {your text}
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const jimp = require('jimp');
module.exports = async (event, context) => {
if (event.content.startsWith(`${process.env.PREFIX}post`)) {
let post = event.content.split(' ');
if (!post[1]) {
return lib.discord.channels['@0.1.1'].messages.create({
channel_id: event.channel_id,
content: `You have to say something!`,
});
}
post = post.slice(1).join(' ');
let username = event.author.username;
let bannerURL = 'https://i.ibb.co/d7QM5Hb/Pics-Art-02-01-11-46-19.jpg'; //change this if you want
let avatarURL = `https://cdn.discordapp.com/avatars/${event.author.id}/${event.author.avatar}.png?size=128`;
let img = await jimp.read(bannerURL);
let avatar = await jimp.read(
event.author.avatar
? avatarURL
: 'https://discord.com/assets/1f0bfc0865d324c2587920a7d80c609b.png'
); // Default to the Discord logo if no avatar supplied
avatar.circle();
avatar.resize(30, 30);
img.composite(avatar, 100, 155);
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => {
img.print(
font,
200,
300,
{
text: post,
alignmentX: jimp.HORIZONTAL_ALIGN_LEFT,
alignmentY: jimp.VERTICAL_ALIGN_TOP,
},
200,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_16_BLACK).then((font) => {
img.print(
font,
150,
165,
{
text: username,
alignmentX: jimp.HORIZONTAL_ALIGN_LEFT,
alignmentY: jimp.VERTICAL_ALIGN_TOP,
},
200,
290
);
});
let buffer = await img.getBufferAsync(jimp.MIME_PNG);
await lib.discord.channels['@0.1.2'].messages.destroy({
message_id: event.id,
channel_id: event.channel_id,
});
return lib.discord.channels['@0.1.1'].messages.create({
channel_id: event.channel_id,
content: ``,
filename: 'post.png',
file: buffer,
});
}
};