aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 10:22:12 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 10:22:12 -0600
commiteab83de75de50add1b5c031f1ca9b8794634b8da (patch)
tree999c3d8ef0a63113d87edd0359fcc46fbbb58bb1 /src/lib/extensions
parent24130f0dd089c1c48907215e1eaf595da2f3b639 (diff)
downloadtanzanite-eab83de75de50add1b5c031f1ca9b8794634b8da.tar.gz
tanzanite-eab83de75de50add1b5c031f1ca9b8794634b8da.tar.bz2
tanzanite-eab83de75de50add1b5c031f1ca9b8794634b8da.zip
add a few more util things and an error handler
Diffstat (limited to 'src/lib/extensions')
-rw-r--r--src/lib/extensions/Util.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index 20bfd48..4942bb8 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -5,6 +5,8 @@ import { promisify } from 'util';
import { exec } from 'child_process';
import got from 'got';
import { TextChannel } from 'discord.js';
+import { MessageEmbed } from 'discord.js';
+import { GuildMember } from 'discord.js';
interface hastebinRes {
key: string;
@@ -193,4 +195,50 @@ export class Util extends ClientUtil {
)) as TextChannel;
await channel.send(`ERROR: ${message}`);
}
+
+ /**
+ * The colors used throught the bot
+ */
+ public colors = {
+ default: '#1FD8F1',
+ error: '#ff0000',
+ success: '#00ff02',
+ red: '#ff0000',
+ blue: '#0055ff',
+ aqua: '#00bbff',
+ purple: '#8400ff',
+ blurple: '#5440cd',
+ pink: '#ff00e6',
+ green: '#00ff1e',
+ darkgreen: '#008f11',
+ gold: '#b59400',
+ yellow: '#ffff00',
+ white: '#ffffff',
+ gray: '#a6a6a6',
+ lightgray: '#cfcfcf',
+ darkgray: '#7a7a7a',
+ black: '#000000',
+ orange: '#E86100'
+ };
+
+ /**
+ * A simple utility to create and embed with the needed style for the bot
+ */
+ public createEmbed(
+ color?: string,
+ author?: User | GuildMember
+ ): MessageEmbed {
+ if (author instanceof GuildMember) {
+ author = author.user; // Convert to User if GuildMember
+ }
+ let embed = new MessageEmbed().setTimestamp();
+ if (author)
+ embed = embed.setAuthor(
+ author.username,
+ author.displayAvatarURL({ dynamic: true }),
+ `https://discord.com/users/${author.id}`
+ );
+ if (color) embed = embed.setColor(color);
+ return embed;
+ }
}