This is a prefix command that visualizes a hex color code, example: `!vasualize #ffffff`, this will send a embedded message with that color and a picture or that color.
// This is a prefix command that visualizes a hex color code, example: `!vasualize #ffffff`, this will send a embedded message with that color and a picture or that color.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
const msg = event.content;
// * ----------------------- * //
if (msg.startsWith ('!visualize')) {
// * ----------------------- * //
if (msg === ('!visualize')) {
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: event.channel_id,
content: `<@${event.author.id}> **${msg}** is the wrong way of using this command, please use \`!visualize <#hex>\` instead. Example: \`!visualize #FF0000\`.`
});
// * ----------------------- * //
} else {
// * ----------------------- * //
const input = msg.split(' ');
console.log(input);
// * ----------------------- * //
const string1 = input[1].toLowerCase();
const string = input[1].toUpperCase();
const hex = string1.split('#')
const color = parseInt(hex[1], 16);
console.log(string1, hex);
// * ----------------------- * //
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: event.channel_id,
content: '',
embeds: [
{
title: `${string}`,
description: '',
color: color,
image: {
url: `https://color-hex.org/colors/${hex[1]}.png`,
hight: 0,
width: 0
},
},
],
});
} }