This command generates a random cool rating number (through a bunch of factors such as the mentioned person's discriminator, username, etc.) and assigns it to whoever is mentioned. If nobody is mentioned, then it assigns the value to the author. This is just for fun and does not actually rate anyone's coolness.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const md5 = require('md5');
const reducer = (accumulator, currentValue) => accumulator + currentValue;
let person = context.params.event.author;
if (context.params.event.mentions.length > 0) {
person = context.params.event.mentions[0];
}
let str = md5(
person.username +
person.discriminator +
person.id +
person.avatar +
person.public_flags
);
let numbers = Array.from(str.matchAll(/[0-9]+/g), (m) => parseInt(m[0]));
let rating = numbers.reduce(reducer, 0);
while (rating > 100) {
rating *= parseFloat('0.' + person.id.charAt(1)) * 0.8;
}
rating = rating.toFixed(2);
let rated = person.username + '#' + person.discriminator;
if (context.params.event.mentions.length > 0) {
rated =
context.params.event.mentions[0].username +
'#' +
context.params.event.mentions[0].discriminator;
}
let message = null;
if (rating === 100) {
message = `You're the coolest person ever! Praise be **${rated.slice(0,-5)}**!`;
}
if (rating >= 75 && rating !== 100) {
message = "You're pretty cool.";
}
if (rating < 75 && rating > 50) {
message = "You're above average in terms of coolness.";
}
if (rating === 50) {
message = "You're the most normal person I know.";
}
if (rating < 50 && rating >= 25) {
message = "You're ok.";
}
if (rating < 25 && rating !== 0) {
message = "You're pretty boring.";
}
if (rating === 0) {
message = "You're the most boring person ever.";
}
if (context.params.event.content.startsWith('!coolrate')) {
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**${rated}** is ${rating}% cool. ${message}`,
});
}
console.log(str);