reduce getTopColor/pastelize imports
This commit is contained in:
		
							parent
							
								
									cdf4589b38
								
							
						
					
					
						commit
						41b587fd58
					
				
					 4 changed files with 8 additions and 24 deletions
				
			
		| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
const logger = require("npmlog");
 | 
					const logger = require("npmlog");
 | 
				
			||||||
 | 
					const {pastelize, getTopColor} = require("./lib/utils.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function parseArguments(str) {
 | 
					function parseArguments(str) {
 | 
				
			||||||
  return str.match(/\\?.|^$/g).reduce(
 | 
					  return str.match(/\\?.|^$/g).reduce(
 | 
				
			||||||
| 
						 | 
					@ -88,6 +89,11 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
        file = response.file;
 | 
					        file = response.file;
 | 
				
			||||||
        delete 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) {
 | 
					      if (response.reaction) {
 | 
				
			||||||
        msg.addReaction(response.reaction);
 | 
					        msg.addReaction(response.reaction);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,11 @@
 | 
				
			||||||
const Command = require("../lib/command.js");
 | 
					const Command = require("../lib/command.js");
 | 
				
			||||||
const CATEGORY = "general";
 | 
					const CATEGORY = "general";
 | 
				
			||||||
const {pastelize, getTopColor} = require("../lib/utils.js");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const help = new Command("help");
 | 
					const help = new Command("help");
 | 
				
			||||||
help.category = CATEGORY;
 | 
					help.category = CATEGORY;
 | 
				
			||||||
help.helpText = "Lists all commands";
 | 
					help.helpText = "Lists all commands";
 | 
				
			||||||
help.usage = "[command] or [--category]";
 | 
					help.usage = "[command] or [--category]";
 | 
				
			||||||
help.callback = function (msg, line) {
 | 
					help.callback = function (msg, line) {
 | 
				
			||||||
  const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
 | 
					 | 
				
			||||||
  const sorted = {};
 | 
					  const sorted = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (const cmd of hf.commands.values()) {
 | 
					  for (const cmd of hf.commands.values()) {
 | 
				
			||||||
| 
						 | 
					@ -21,7 +19,6 @@ help.callback = function (msg, line) {
 | 
				
			||||||
  if (line == "") {
 | 
					  if (line == "") {
 | 
				
			||||||
    const embed = {
 | 
					    const embed = {
 | 
				
			||||||
      title: "HiddenPhox Help",
 | 
					      title: "HiddenPhox Help",
 | 
				
			||||||
      color,
 | 
					 | 
				
			||||||
      fields: [],
 | 
					      fields: [],
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +41,6 @@ help.callback = function (msg, line) {
 | 
				
			||||||
        title: `HiddenPhox Help: Category > ${
 | 
					        title: `HiddenPhox Help: Category > ${
 | 
				
			||||||
          cat.toUpperCase().charAt(0) + cat.toLowerCase().substring(1)
 | 
					          cat.toUpperCase().charAt(0) + cat.toLowerCase().substring(1)
 | 
				
			||||||
        }`,
 | 
					        }`,
 | 
				
			||||||
        color,
 | 
					 | 
				
			||||||
        fields: [],
 | 
					        fields: [],
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,7 +72,6 @@ help.callback = function (msg, line) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const embed = {
 | 
					      const embed = {
 | 
				
			||||||
        title: `HiddenPhox Help: Command > \`${hf.config.prefix}${cmd.name}\``,
 | 
					        title: `HiddenPhox Help: Command > \`${hf.config.prefix}${cmd.name}\``,
 | 
				
			||||||
        color,
 | 
					 | 
				
			||||||
        description: cmd.helpText,
 | 
					        description: cmd.helpText,
 | 
				
			||||||
        fields: [
 | 
					        fields: [
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,12 +2,7 @@ const Command = require("../lib/command.js");
 | 
				
			||||||
const CATEGORY = "misc";
 | 
					const CATEGORY = "misc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					const fetch = require("node-fetch");
 | 
				
			||||||
const {
 | 
					const {safeString, parseHtmlEntities} = require("../lib/utils.js");
 | 
				
			||||||
  getTopColor,
 | 
					 | 
				
			||||||
  pastelize,
 | 
					 | 
				
			||||||
  safeString,
 | 
					 | 
				
			||||||
  parseHtmlEntities,
 | 
					 | 
				
			||||||
} = require("../lib/utils.js");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const yt = new Command("youtube");
 | 
					const yt = new Command("youtube");
 | 
				
			||||||
yt.addAlias("yt");
 | 
					yt.addAlias("yt");
 | 
				
			||||||
| 
						 | 
					@ -98,7 +93,6 @@ wolfram.callback = async function (msg, line) {
 | 
				
			||||||
  if (verbose) {
 | 
					  if (verbose) {
 | 
				
			||||||
    const embed = {
 | 
					    const embed = {
 | 
				
			||||||
      title: `Result for: \`${safeString(line)}\``,
 | 
					      title: `Result for: \`${safeString(line)}\``,
 | 
				
			||||||
      color: getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id)),
 | 
					 | 
				
			||||||
      fields: [],
 | 
					      fields: [],
 | 
				
			||||||
      footer: {
 | 
					      footer: {
 | 
				
			||||||
        icon_url: "http://www.wolframalpha.com/share.png",
 | 
					        icon_url: "http://www.wolframalpha.com/share.png",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,15 +13,13 @@ const STATUS_ICONS = {
 | 
				
			||||||
  offline: "<:offline:493173082253426688>",
 | 
					  offline: "<:offline:493173082253426688>",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {pastelize, getTopColor, lookupUser} = require("../lib/utils.js");
 | 
					const {lookupUser} = require("../lib/utils.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const avatar = new Command("avatar");
 | 
					const avatar = new Command("avatar");
 | 
				
			||||||
avatar.category = CATEGORY;
 | 
					avatar.category = CATEGORY;
 | 
				
			||||||
avatar.helpText = "Get avatar of a user";
 | 
					avatar.helpText = "Get avatar of a user";
 | 
				
			||||||
avatar.usage = "<user>";
 | 
					avatar.usage = "<user>";
 | 
				
			||||||
avatar.callback = async function (msg, line) {
 | 
					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 (line == "--server" || line == "--guild") {
 | 
				
			||||||
    if (!msg.channel.guild) {
 | 
					    if (!msg.channel.guild) {
 | 
				
			||||||
      return "`--server/--guild` can only be used within guilds.";
 | 
					      return "`--server/--guild` can only be used within guilds.";
 | 
				
			||||||
| 
						 | 
					@ -35,7 +33,6 @@ avatar.callback = async function (msg, line) {
 | 
				
			||||||
      }`;
 | 
					      }`;
 | 
				
			||||||
      return {
 | 
					      return {
 | 
				
			||||||
        embed: {
 | 
					        embed: {
 | 
				
			||||||
          color,
 | 
					 | 
				
			||||||
          title: "Server Icon",
 | 
					          title: "Server Icon",
 | 
				
			||||||
          url,
 | 
					          url,
 | 
				
			||||||
          image: {
 | 
					          image: {
 | 
				
			||||||
| 
						 | 
					@ -58,7 +55,6 @@ avatar.callback = async function (msg, line) {
 | 
				
			||||||
      }`;
 | 
					      }`;
 | 
				
			||||||
      return {
 | 
					      return {
 | 
				
			||||||
        embed: {
 | 
					        embed: {
 | 
				
			||||||
          color,
 | 
					 | 
				
			||||||
          title: `Avatar for \`${user.username}#${user.discriminator}\``,
 | 
					          title: `Avatar for \`${user.username}#${user.discriminator}\``,
 | 
				
			||||||
          url,
 | 
					          url,
 | 
				
			||||||
          image: {
 | 
					          image: {
 | 
				
			||||||
| 
						 | 
					@ -75,7 +71,6 @@ avatar.callback = async function (msg, line) {
 | 
				
			||||||
    }`;
 | 
					    }`;
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
      embed: {
 | 
					      embed: {
 | 
				
			||||||
        color,
 | 
					 | 
				
			||||||
        title: `Avatar for \`${msg.author.username}#${msg.author.discriminator}\``,
 | 
					        title: `Avatar for \`${msg.author.username}#${msg.author.discriminator}\``,
 | 
				
			||||||
        url,
 | 
					        url,
 | 
				
			||||||
        image: {
 | 
					        image: {
 | 
				
			||||||
| 
						 | 
					@ -92,8 +87,6 @@ banner.category = CATEGORY;
 | 
				
			||||||
banner.helpText = "Get banner of a user";
 | 
					banner.helpText = "Get banner of a user";
 | 
				
			||||||
banner.usage = "<user>";
 | 
					banner.usage = "<user>";
 | 
				
			||||||
banner.callback = async function (msg, line) {
 | 
					banner.callback = async function (msg, line) {
 | 
				
			||||||
  const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  let id = msg.author.id;
 | 
					  let id = msg.author.id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (line) {
 | 
					  if (line) {
 | 
				
			||||||
| 
						 | 
					@ -118,7 +111,6 @@ banner.callback = async function (msg, line) {
 | 
				
			||||||
  }`;
 | 
					  }`;
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    embed: {
 | 
					    embed: {
 | 
				
			||||||
      color,
 | 
					 | 
				
			||||||
      title: `Banner for \`${user.username}#${user.discriminator}\``,
 | 
					      title: `Banner for \`${user.username}#${user.discriminator}\``,
 | 
				
			||||||
      url,
 | 
					      url,
 | 
				
			||||||
      image: {
 | 
					      image: {
 | 
				
			||||||
| 
						 | 
					@ -135,8 +127,6 @@ lookupinvite.helpText = "Lookup an invite";
 | 
				
			||||||
lookupinvite.usage = "<invite code>";
 | 
					lookupinvite.usage = "<invite code>";
 | 
				
			||||||
lookupinvite.addAlias("linvite");
 | 
					lookupinvite.addAlias("linvite");
 | 
				
			||||||
lookupinvite.callback = async function (msg, line) {
 | 
					lookupinvite.callback = async function (msg, line) {
 | 
				
			||||||
  const color = getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (!line) {
 | 
					  if (!line) {
 | 
				
			||||||
    return "No arguments passed.";
 | 
					    return "No arguments passed.";
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -157,7 +147,6 @@ lookupinvite.callback = async function (msg, line) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    const embed = {
 | 
					    const embed = {
 | 
				
			||||||
      color,
 | 
					 | 
				
			||||||
      title: `Invite Info: \`${invite.code}\``,
 | 
					      title: `Invite Info: \`${invite.code}\``,
 | 
				
			||||||
      description: invite.description,
 | 
					      description: invite.description,
 | 
				
			||||||
      fields: [
 | 
					      fields: [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue