From 1def142b1ddff9e377262699f0c74891348ac1de Mon Sep 17 00:00:00 2001 From: rhearmas <34490428+qu-ota@users.noreply.github.com> Date: Fri, 13 Dec 2019 11:15:11 -0500 Subject: [PATCH] embed command --- cmds_SharpBot/Utility/embed.js | 2 ++ commands/Utility/embed.js | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 commands/Utility/embed.js diff --git a/cmds_SharpBot/Utility/embed.js b/cmds_SharpBot/Utility/embed.js index beca30e..4af4cfa 100644 --- a/cmds_SharpBot/Utility/embed.js +++ b/cmds_SharpBot/Utility/embed.js @@ -1,3 +1,5 @@ +// This command has already been completed. + exports.run = (bot, msg, args) => { if (args.length < 1) { throw 'You must specify something to embed!'; diff --git a/commands/Utility/embed.js b/commands/Utility/embed.js new file mode 100644 index 0000000..f53c168 --- /dev/null +++ b/commands/Utility/embed.js @@ -0,0 +1,51 @@ +exports.run = async (client, message, args, level) => { + if (!args[0]) { + return message.reply("you must specify some stuff to put into the embed."); + } + + let parsed = bot.utils.parseArgs(args, ['f', 'ft:', 'd', 't:', 'c:', 'r', 'i:', 'a:', 'th:']); + + let color = parsed.options.c; + if (parsed.options.r && msg.guild && msg.guild.members) { + let member = msg.guild.members.get(msg.author.id); + if (member) { + color = member.highestRole.hexColor; + } + } + + if (color) { + if (!color.startsWith('#')) { + color = `#${color}`; + } + + if (!/^#[a-fA-F0-9]{6}$/.test(color)) { + return message.reply(`color \`${color}\` is invalid. Please use valid hex format (\`#RRGGBB\`)`); + } + } + + message.delete(); + message.channel.send({ + embed: bot.utils.embed(parsed.options.t || '', parsed.leftover.join(' '), [], { + footer: parsed.options.f || parsed.options.ft, + timestamp: parsed.options.d, + color, + image: parsed.options.i, + author: parsed.options.a, + thumbnail: parsed.options.th + }) + }); +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "Admin" +}; + +exports.help = { + name: "embed", + category: "Utility", + description: "Send a message via embeds.", + usage: "embed [text]" +};