ship you and somone else to see your percentage on a cute little card! You must create a command in Autocode Slash Command Builder named ship and you must have one string called user (for the user they want to find compatibility with). Just insert your bot prefix in the environment variables! (you can change the command name in the endpoint)
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const jimp = require('jimp');
const event = context.params.event;
const percent = [
'1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%', '10%', '11%', '12%', '13%', '14%', '15%', '16%', '17%', '18%', '19%', '20%', '21%', '22%', '23%', '24%', '25%', '26%', '27%', '28%', '29%', '30%', '31%', '32%', '33%', '34%', '35%', '36%', '37%', '38%', '39%', '40%', '41%', '42%', '43%', '44%', '45%', '46%', '47%', '48%', '49%', '50%', '51%', '52%', '53%', '54%', '55%', '56%', '57%', '58%', '59%', '60%', '61%', '62%', '63%', '64%', '65%', '66%', '67%', '68%', '69%', '70%', '71%', '72%', '73%', '74%', '75%', '76%', '77%', '78%', '79%', '80%', '81%', '82%', '83%', '84%', '85%', '86%', '87%', '88%', '89%', '90%', '91%', '92%', '93%', '94%', '95%', '96%', '97%', '98%', '99%', '100%'
];
const compatibility = percent[Math.floor(Math.random() * percent.length)];
const guild = context.params.event.guild_id;
const channel_id = `${process.env.channel}`//insert your channel_id here
let user = event.data.options[0].value;
console.log(user)
let user2 = await lib.discord.guilds['@0.2.4'].members.retrieve({
user_id: `${user}`,
guild_id: `${guild}`
});
let username = user2.username;
console.log(username)
if (!user || !user.match(/<@.*>/)) {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${channel_id}`,
content: ``,
embed: {
title: `Uh-Oh :(`,//you can change this
description: `Please give us someone to ship you with. We can't ship you with no one....`,//you can change this
color: 0xffc0cb, // may be changed
},
});
} else if (user) {
let member = event.member.user.id;
let member2 = event.data.options[0].value;
let user1 = await lib.discord.users['@0.1.4'].retrieve({
user_id: member,
});
let user2 = await lib.discord.users['@0.2.0'].retrieve({
user_id: member2,
});
let img = await jimp.read(
'https://ucarecdn.com/42e73ef9-baa4-4d07-ab08-eda292db0a4a/Untitled64_20220324231414.png'//you can change this, but you will have to edit the avatar sizes and positioning of the percentage. (if you don't know how to do this it's best to leave it alone)
);
let avatar_jimp = await jimp.read(user1.avatar_url);
avatar_jimp.circle();
avatar_jimp.resize(455, 455);
img.composite(avatar_jimp, 120, 270);
let avatar_jimp2 = await jimp.read(user2.avatar_url);
avatar_jimp2.circle();
avatar_jimp2.resize(455, 455);
img.composite(avatar_jimp2, 920, 270);
await jimp.loadFont(jimp.FONT_SANS_64_WHITE).then((font) => {
img.print(
font,
600,
455,
{
text: `${compatibility}`,
alignmentX: jimp.HORIZONTAL_ALIGN_CENTER,
alignmentY: jimp.VERTICAL_ALIGN_CENTER
},
300,
2
);
});
await jimp.loadFont(jimp.FONT_SANS_64_WHITE).then((font) => {
img.print(
font,
120,
113,
{
text: `${event.member.user.username}`,
},
1000,
15
);
});
await jimp.loadFont(jimp.FONT_SANS_64_WHITE).then((font) => {
img.print(
font,
920,
113,
{
text: `${user2.username}`,
},
1000,
15
);
});
let buffer = await img.getBufferAsync(jimp.MIME_PNG);
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: context.params.event.channel_id,
content: `<@!${event.member.user.id}> and <@!${user2.id}> are a ${compatibility} match! :D`,//you can change what is in green
filename: 'your_level.png',
file: buffer,
});
};