This command makes a picture of a fake tweet with your name , avatar, etc. To set up the slash command there are instructions from lines 4-10. then you can do /tweet color: Dark Mode message: Hello guys
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const jimp = require('jimp');
//IMPORTANT: To setup this snippet you need to open the slash command builder
//IMPORTANT: Then make a new command and name it "tweet", and add to string options to it
//IMPORTANT: Then make the first option named "color" and then add 2 advanced options to that
//IMPORTANT: Name those 2 options Light Mode and Dark Mode and set their values to dark and light
//IMPORTANT: Finally on the 2nd option name it message and click save.
//IMPORTANT: If you have any questions about the setup @ROLD_GOLD in the autocode server.
let tweet = context.params.event.data.options[1].value;
//The possible amout of likes
let likeOptions = [
`10,021`,
`56,132`,
`87,623`,
`95,670`,
`13,465`,
`143`,
`46,923`,
`12,687`,
];
let selectedLike = Math.floor(Math.random() * likeOptions.length);
let likeAmount = likeOptions[selectedLike];
//The possible amount of retweets
let reOptions = [
`10,021`,
`56,132`,
`87,623`,
`95,670`,
`13,465`,
`143`,
`46,923`,
`12,687`,
`69,420`,
];
let selectedre = Math.floor(Math.random() * reOptions.length);
let retweetAmount = reOptions[selectedre];
//The light mode options code...
if (context.params.event.data.options[0].value === `light`) {
let bannerURL =
'https://cdn.discordapp.com/attachments/884480105131413504/921879385466884146/file1.jpg';
let avatarURL = `https://cdn.discordapp.com/avatars/${context.params.event.member.user.id}/${context.params.event.member.user.avatar}.png?size=128`;
let img = await jimp.read(bannerURL);
let avatar = await jimp.read(
context.params.event.member.user.avatar //Avatar
? avatarURL
: 'https://discord.com/assets/1f0bfc0865d324c2587920a7d80c609b.png'
);
img.resize(798, 400);
avatar.circle();
avatar.resize(90, 90);
img.composite(avatar, 40, 38);
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => { //Message
img.print(
font,
40,
150,
{
text: tweet,
},
400,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => { //Big username
img.print(
font,
145,
60,
{
text: `${context.params.event.member.user.username}`,
},
290,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_16_BLACK).then((font) => { //Small @ username
img.print(
font,
145,
100,
{
text: `@${context.params.event.member.user.username}`,
},
290,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_16_BLACK).then((font) => { //Likes and Retweets
img.print(
font,
30,
320,
{
text: `${retweetAmount} - ${likeAmount}`,
},
290,
290
);
});
let buffer = await img.getBufferAsync(jimp.MIME_PNG);
return lib.discord.channels['@0.1.1'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
filename: 'tweet.png',
file: buffer,
});
}
//The dark mode options code...
if (context.params.event.data.options[0].value === `dark`) {
let bannerURL =
'https://cdn.discordapp.com/attachments/884480105131413504/921876982042595389/file.jpg';
let avatarURL = `https://cdn.discordapp.com/avatars/${context.params.event.member.user.id}/${context.params.event.member.user.avatar}.png?size=128`;
let img = await jimp.read(bannerURL);
let avatar = await jimp.read( //Avatar
context.params.event.member.user.avatar
? avatarURL
: 'https://discord.com/assets/1f0bfc0865d324c2587920a7d80c609b.png'
);
img.resize(798, 400);
avatar.circle();
avatar.resize(90, 90);
img.composite(avatar, 40, 38);
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => { //Message
img.print(
font,
40,
150,
{
text: tweet,
},
400,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_32_BLACK).then((font) => { //Big username
img.print(
font,
145,
60,
{
text: `${context.params.event.member.user.username}`,
},
290,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_16_BLACK).then((font) => { //Small @ username
img.print(
font,
145,
100,
{
text: `@${context.params.event.member.user.username}`,
},
290,
290
);
});
await jimp.loadFont(jimp.FONT_SANS_16_BLACK).then((font) => { //Likes and Retweets
img.print(
font,
30,
320,
{
text: `${retweetAmount} - ${likeAmount}`,
},
290,
290
);
});
let buffer = await img.getBufferAsync(jimp.MIME_PNG);
return lib.discord.channels['@0.1.1'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
filename: 'tweet.png',
file: buffer,
});
}