Whenever you ask the bot '-coolrate <person>', it will (randomly) generate a number from 0 to 100 and assign that value to the person mentioned. If nobody is mentioned, it rates the author on how cool they are.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let rating = Math.floor(Math.random() * 100);
let rated =
context.params.event.author.username +
'#' +
context.params.event.author.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}`,
});
}