Converts the message after the command into a tweet image! It's best to add this to the economy app that you have installed from me since it has the "prefix" environmental variable. Have fun!
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}tweet`)) {
let tweet = event.content.split(' ');
if (!tweet[1]) {
return lib.discord.channels['@0.1.1'].messages.create({
channel_id: event.channel_id,
content: `You have to say something!`
});
}
tweet = tweet.slice(1).join(' ');
let bannerURL = 'https://cdn.discordapp.com/attachments/859426826786177066/862874414013874236/unknown.png'; //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
img.resize(798, 507);
avatar.circle();
avatar.resize(30, 30);
img.composite(avatar, 244, 122);
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then(font => {
img.print(
font,
285,
117,
{
text: tweet,
alignmentX: jimp.HORIZONTAL_ALIGN_LEFT,
alignmentY: jimp.VERTICAL_ALIGN_TOP
},
290,
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: 'tweet.png',
file: buffer,
});
}
}