reduce getTopColor/pastelize imports

This commit is contained in:
Cynthia Foxwell 2021-08-11 20:41:28 -06:00
parent cdf4589b38
commit 41b587fd58
4 changed files with 8 additions and 24 deletions

View File

@ -1,4 +1,5 @@
const logger = require("npmlog");
const {pastelize, getTopColor} = require("./lib/utils.js");
function parseArguments(str) {
return str.match(/\\?.|^$/g).reduce(
@ -88,6 +89,11 @@ async function CommandDispatcher(msg) {
file = response.file;
delete response.file;
}
if (response.embed) {
response.embed.color =
response.embed.color ||
getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
}
if (response.reaction) {
msg.addReaction(response.reaction);
} else {

View File

@ -1,13 +1,11 @@
const Command = require("../lib/command.js");
const CATEGORY = "general";
const {pastelize, getTopColor} = require("../lib/utils.js");
const help = new Command("help");
help.category = CATEGORY;
help.helpText = "Lists all commands";
help.usage = "[command] or [--category]";
help.callback = function (msg, line) {
const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
const sorted = {};
for (const cmd of hf.commands.values()) {
@ -21,7 +19,6 @@ help.callback = function (msg, line) {
if (line == "") {
const embed = {
title: "HiddenPhox Help",
color,
fields: [],
};
@ -44,7 +41,6 @@ help.callback = function (msg, line) {
title: `HiddenPhox Help: Category > ${
cat.toUpperCase().charAt(0) + cat.toLowerCase().substring(1)
}`,
color,
fields: [],
};
@ -76,7 +72,6 @@ help.callback = function (msg, line) {
const embed = {
title: `HiddenPhox Help: Command > \`${hf.config.prefix}${cmd.name}\``,
color,
description: cmd.helpText,
fields: [
{

View File

@ -2,12 +2,7 @@ const Command = require("../lib/command.js");
const CATEGORY = "misc";
const fetch = require("node-fetch");
const {
getTopColor,
pastelize,
safeString,
parseHtmlEntities,
} = require("../lib/utils.js");
const {safeString, parseHtmlEntities} = require("../lib/utils.js");
const yt = new Command("youtube");
yt.addAlias("yt");
@ -98,7 +93,6 @@ wolfram.callback = async function (msg, line) {
if (verbose) {
const embed = {
title: `Result for: \`${safeString(line)}\``,
color: getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id)),
fields: [],
footer: {
icon_url: "http://www.wolframalpha.com/share.png",

View File

@ -13,15 +13,13 @@ const STATUS_ICONS = {
offline: "<:offline:493173082253426688>",
};
const {pastelize, getTopColor, lookupUser} = require("../lib/utils.js");
const {lookupUser} = require("../lib/utils.js");
const avatar = new Command("avatar");
avatar.category = CATEGORY;
avatar.helpText = "Get avatar of a user";
avatar.usage = "<user>";
avatar.callback = async function (msg, line) {
const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
if (line == "--server" || line == "--guild") {
if (!msg.channel.guild) {
return "`--server/--guild` can only be used within guilds.";
@ -35,7 +33,6 @@ avatar.callback = async function (msg, line) {
}`;
return {
embed: {
color,
title: "Server Icon",
url,
image: {
@ -58,7 +55,6 @@ avatar.callback = async function (msg, line) {
}`;
return {
embed: {
color,
title: `Avatar for \`${user.username}#${user.discriminator}\``,
url,
image: {
@ -75,7 +71,6 @@ avatar.callback = async function (msg, line) {
}`;
return {
embed: {
color,
title: `Avatar for \`${msg.author.username}#${msg.author.discriminator}\``,
url,
image: {
@ -92,8 +87,6 @@ banner.category = CATEGORY;
banner.helpText = "Get banner of a user";
banner.usage = "<user>";
banner.callback = async function (msg, line) {
const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
let id = msg.author.id;
if (line) {
@ -118,7 +111,6 @@ banner.callback = async function (msg, line) {
}`;
return {
embed: {
color,
title: `Banner for \`${user.username}#${user.discriminator}\``,
url,
image: {
@ -135,8 +127,6 @@ lookupinvite.helpText = "Lookup an invite";
lookupinvite.usage = "<invite code>";
lookupinvite.addAlias("linvite");
lookupinvite.callback = async function (msg, line) {
const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
if (!line) {
return "No arguments passed.";
}
@ -157,7 +147,6 @@ lookupinvite.callback = async function (msg, line) {
}
} else {
const embed = {
color,
title: `Invite Info: \`${invite.code}\``,
description: invite.description,
fields: [