aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-28 21:54:50 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-28 21:54:50 -0600
commit2456dab3db0d8eaae515606b83a6c0c317d009b0 (patch)
treec20448112d43c1b4ffae1395584d9b202aeee3ed /src/lib
parent1e9e334097702c68d871365fc016aa096d03c491 (diff)
parent5b5f0bf5667b922037508dfa88e40a1f8a2671ec (diff)
downloadtanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.tar.gz
tanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.tar.bz2
tanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.zip
fix conflicts
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/extensions/BotInhibitor.ts6
-rw-r--r--src/lib/extensions/BotListener.ts6
-rw-r--r--src/lib/extensions/BotTask.ts6
-rw-r--r--src/lib/extensions/BushClient.ts (renamed from src/lib/extensions/BotClient.ts)37
-rw-r--r--src/lib/extensions/BushCommand.ts (renamed from src/lib/extensions/BotCommand.ts)10
-rw-r--r--src/lib/extensions/BushInhibitor.ts6
-rw-r--r--src/lib/extensions/BushListener.ts6
-rw-r--r--src/lib/extensions/BushTask.ts6
-rw-r--r--src/lib/extensions/Util.ts37
-rw-r--r--src/lib/models/Ban.ts5
-rw-r--r--src/lib/models/Guild.ts9
-rw-r--r--src/lib/models/Modlog.ts14
-rw-r--r--src/lib/utils/AllowedMentions.ts6
-rw-r--r--src/lib/utils/Console.ts93
-rw-r--r--src/lib/utils/Logger.ts12
15 files changed, 148 insertions, 111 deletions
diff --git a/src/lib/extensions/BotInhibitor.ts b/src/lib/extensions/BotInhibitor.ts
deleted file mode 100644
index 960aade..0000000
--- a/src/lib/extensions/BotInhibitor.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Inhibitor } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotInhibitor extends Inhibitor {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotListener.ts b/src/lib/extensions/BotListener.ts
deleted file mode 100644
index 9ec17b2..0000000
--- a/src/lib/extensions/BotListener.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Listener } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotListener extends Listener {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotTask.ts b/src/lib/extensions/BotTask.ts
deleted file mode 100644
index 4d5cdcd..0000000
--- a/src/lib/extensions/BotTask.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Task } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotTask extends Task {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BushClient.ts
index 13c8a76..8a0fc8c 100644
--- a/src/lib/extensions/BotClient.ts
+++ b/src/lib/extensions/BushClient.ts
@@ -1,10 +1,4 @@
-import {
- AkairoClient,
- CommandHandler,
- InhibitorHandler,
- ListenerHandler,
- TaskHandler
-} from 'discord-akairo';
+import { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler, TaskHandler } from 'discord-akairo';
import { Guild } from 'discord.js';
import * as path from 'path';
import { Sequelize } from 'sequelize';
@@ -18,7 +12,7 @@ import chalk from 'chalk';
export type BotConfig = typeof config;
-export class BotClient extends AkairoClient {
+export class BushClient extends AkairoClient {
public config: BotConfig;
public listenerHandler: ListenerHandler;
public inhibitorHandler: InhibitorHandler;
@@ -89,17 +83,12 @@ export class BotClient extends AkairoClient {
});
this.util = new Util(this);
- this.db = new Sequelize(
- this.config.dev ? 'bushbot-dev' : 'bushbot',
- this.config.db.username,
- this.config.db.password,
- {
- dialect: 'postgres',
- host: this.config.db.host,
- port: this.config.db.port,
- logging: false
- }
- );
+ this.db = new Sequelize(this.config.dev ? 'bushbot-dev' : 'bushbot', this.config.db.username, this.config.db.password, {
+ dialect: 'postgres',
+ host: this.config.db.host,
+ port: this.config.db.port,
+ logging: false
+ });
this.logger = new Logger(this);
}
@@ -122,15 +111,9 @@ export class BotClient extends AkairoClient {
for (const loader of Object.keys(loaders)) {
try {
loaders[loader].loadAll();
- this.logger.log(
- chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.')
- );
+ this.logger.log(chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.'));
} catch (e) {
- console.error(
- chalk.red(
- 'Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e
- )
- );
+ console.error(chalk.red('Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e));
}
}
this.taskHandler.startAll();
diff --git a/src/lib/extensions/BotCommand.ts b/src/lib/extensions/BushCommand.ts
index c5d31e9..4f9dc6e 100644
--- a/src/lib/extensions/BotCommand.ts
+++ b/src/lib/extensions/BushCommand.ts
@@ -1,8 +1,8 @@
import { Command, CommandOptions } from 'discord-akairo';
import { APIApplicationCommandOption } from 'discord-api-types';
-import { BotClient } from './BotClient';
+import { BushClient } from './BushClient';
-export interface BotCommandOptions extends CommandOptions {
+export interface BushCommandOptions extends CommandOptions {
slashCommandOptions?: APIApplicationCommandOption[];
description: {
content: string;
@@ -11,9 +11,9 @@ export interface BotCommandOptions extends CommandOptions {
};
}
-export class BotCommand extends Command {
- public client: BotClient;
- constructor(id: string, options?: BotCommandOptions) {
+export class BushCommand extends Command {
+ public client: BushClient;
+ constructor(id: string, options?: BushCommandOptions) {
super(id, options);
this.options = options;
}
diff --git a/src/lib/extensions/BushInhibitor.ts b/src/lib/extensions/BushInhibitor.ts
new file mode 100644
index 0000000..d9a9b68
--- /dev/null
+++ b/src/lib/extensions/BushInhibitor.ts
@@ -0,0 +1,6 @@
+import { Inhibitor } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushInhibitor extends Inhibitor {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/BushListener.ts b/src/lib/extensions/BushListener.ts
new file mode 100644
index 0000000..6a13210
--- /dev/null
+++ b/src/lib/extensions/BushListener.ts
@@ -0,0 +1,6 @@
+import { Listener } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushListener extends Listener {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/BushTask.ts b/src/lib/extensions/BushTask.ts
new file mode 100644
index 0000000..21655e9
--- /dev/null
+++ b/src/lib/extensions/BushTask.ts
@@ -0,0 +1,6 @@
+import { Task } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushTask extends Task {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index 5e9d5e7..3e6882a 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -1,16 +1,11 @@
import { ClientUtil } from 'discord-akairo';
-import { BotClient } from './BotClient';
+import { BushClient } from './BushClient';
import { promisify } from 'util';
import { exec } from 'child_process';
import got from 'got';
import { MessageEmbed, GuildMember, User } from 'discord.js';
import { CommandInteractionOption } from 'discord.js';
-import {
- ApplicationCommandOptionType,
- APIInteractionDataResolvedGuildMember,
- APIInteractionDataResolvedChannel,
- APIRole
-} from 'discord-api-types';
+import { ApplicationCommandOptionType, APIInteractionDataResolvedGuildMember, APIInteractionDataResolvedChannel, APIRole } from 'discord-api-types';
import { GuildChannel } from 'discord.js';
import { Role } from 'discord.js';
import chalk from 'chalk';
@@ -57,9 +52,9 @@ export interface SlashCommandOption<T> {
export class Util extends ClientUtil {
/**
* The client of this ClientUtil
- * @type {BotClient}
+ * @type {BushClient}
*/
- public client: BotClient;
+ public client: BushClient;
/**
* The hastebin urls used to post to hastebin, attempts to post in order
* @type {string[]}
@@ -83,7 +78,7 @@ export class Util extends ClientUtil {
* Creates this client util
* @param client The client to initialize with
*/
- constructor(client: BotClient) {
+ constructor(client: BushClient) {
super(client);
}
@@ -125,9 +120,7 @@ export class Util extends ClientUtil {
public async haste(content: string): Promise<string> {
for (const url of this.hasteURLs) {
try {
- const res: hastebinRes = await got
- .post(`${url}/documents`, { body: content })
- .json();
+ const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json();
return `${url}/${res.key}`;
} catch (e) {
// pass
@@ -220,28 +213,18 @@ export class Util extends ClientUtil {
/**
* A simple utility to create and embed with the needed style for the bot
*/
- public createEmbed(
- color?: string,
- author?: User | GuildMember
- ): MessageEmbed {
+ 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 (author) embed = embed.setAuthor(author.username, author.displayAvatarURL({ dynamic: true }), `https://discord.com/users/${author.id}`);
if (color) embed = embed.setColor(color);
return embed;
}
public async mcUUID(username: string): Promise<string> {
- const apiRes = (await got
- .get(`https://api.ashcon.app/mojang/v2/user/${username}`)
- .json()) as uuidRes;
+ const apiRes = (await got.get(`https://api.ashcon.app/mojang/v2/user/${username}`).json()) as uuidRes;
return apiRes.uuid.replace(/-/g, '');
}
@@ -281,7 +264,7 @@ export class Util extends ClientUtil {
name: botCommand.id,
description: botCommand.description.content,
options: botCommand.options.slashCommandOptions
- };
+ };botCommand
if (found?.id && !force) {
if (slashdata.description !== found.description) {
diff --git a/src/lib/models/Ban.ts b/src/lib/models/Ban.ts
index ab7b38d..66c1be9 100644
--- a/src/lib/models/Ban.ts
+++ b/src/lib/models/Ban.ts
@@ -20,10 +20,7 @@ export interface BanModelCreationAttributes {
modlog: string;
}
-export class Ban
- extends BaseModel<BanModel, BanModelCreationAttributes>
- implements BanModel
-{
+export class Ban extends BaseModel<BanModel, BanModelCreationAttributes> implements BanModel {
/**
* The ID of this ban (no real use just for a primary key)
*/
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 1cb3abb..7902461 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -1,5 +1,5 @@
import { DataTypes, Optional, Sequelize } from 'sequelize';
-import { BotClient } from '../extensions/BotClient';
+import { BushClient } from '../extensions/BushClient';
import { BaseModel } from './BaseModel';
export interface GuildModel {
@@ -8,13 +8,10 @@ export interface GuildModel {
}
export type GuildModelCreationAttributes = Optional<GuildModel, 'prefix'>;
-export class Guild
- extends BaseModel<GuildModel, GuildModelCreationAttributes>
- implements GuildModel
-{
+export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> implements GuildModel {
id: string;
prefix: string;
- static initModel(seqeulize: Sequelize, client: BotClient): void {
+ static initModel(seqeulize: Sequelize, client: BushClient): void {
Guild.init(
{
id: {
diff --git a/src/lib/models/Modlog.ts b/src/lib/models/Modlog.ts
index 7e24ba6..3917a88 100644
--- a/src/lib/models/Modlog.ts
+++ b/src/lib/models/Modlog.ts
@@ -32,10 +32,7 @@ export interface ModlogModelCreationAttributes {
guild: string;
}
-export class Modlog
- extends BaseModel<ModlogModel, ModlogModelCreationAttributes>
- implements ModlogModel
-{
+export class Modlog extends BaseModel<ModlogModel, ModlogModelCreationAttributes> implements ModlogModel {
id: string;
type: ModlogType;
user: string;
@@ -54,14 +51,7 @@ export class Modlog
defaultValue: uuidv4
},
type: {
- type: new DataTypes.ENUM(
- 'BAN',
- 'TEMPBAN',
- 'MUTE',
- 'TEMPMUTE',
- 'KICK',
- 'WARN'
- ),
+ type: new DataTypes.ENUM('BAN', 'TEMPBAN', 'MUTE', 'TEMPMUTE', 'KICK', 'WARN'),
allowNull: false
},
user: {
diff --git a/src/lib/utils/AllowedMentions.ts b/src/lib/utils/AllowedMentions.ts
index 47e440b..68c44d7 100644
--- a/src/lib/utils/AllowedMentions.ts
+++ b/src/lib/utils/AllowedMentions.ts
@@ -34,11 +34,7 @@ export default class AllowedMentions {
}
public toObject(): MessageMentionOptions {
return {
- parse: [
- ...(this.users ? ['users'] : []),
- ...(this.roles ? ['roles'] : []),
- ...(this.everyone ? ['everyone'] : [])
- ] as MessageMentionTypes[]
+ parse: [...(this.users ? ['users'] : []), ...(this.roles ? ['roles'] : []), ...(this.everyone ? ['everyone'] : [])] as MessageMentionTypes[]
};
}
}
diff --git a/src/lib/utils/Console.ts b/src/lib/utils/Console.ts
new file mode 100644
index 0000000..b74ea07
--- /dev/null
+++ b/src/lib/utils/Console.ts
@@ -0,0 +1,93 @@
+// import chalk from 'chalk';
+// import { BushClient } from '../extensions/BushClient';
+
+// export class CustomConsole {
+// private client: BushClient;
+// public constructor(client: BushClient) {
+// this.client = client;
+// }
+
+// private parseColors(content: any, color: 'blueBright' | 'blackBright' | 'redBright' | 'yellowBright' | 'greenBright'): string | any {
+// if (typeof content === 'string') {
+// const newContent: Array<string> = content.split(/<<|>>/);
+// const tempParsedArray: Array<string> = [];
+// newContent.forEach((value, index) => {
+// if (index % 2 !== 0) {
+// tempParsedArray.push(chalk[color](value));
+// } else {
+// tempParsedArray.push(value);
+// }
+// });
+// return tempParsedArray.join('');
+// } else {
+// return content;
+// }
+// }
+
+// private timeStamp(): string {
+// const now = new Date();
+// const hours = now.getHours();
+// const minute = now.getMinutes();
+// let hour = hours;
+// let amOrPm: 'AM' | 'PM' = 'AM';
+// if (hour > 12) {
+// amOrPm = 'PM';
+// hour = hour - 12;
+// }
+
+// return `${hour >= 10 ? hour : `0${hour}`}:${minute >= 10 ? minute : `0${minute}`} ${amOrPm}`;
+// }
+
+// /**
+// * Logs debug information.
+// * @param content - The content to log.
+// */
+// public debug(content: any): void {
+// console.log(`${chalk.bgGrey(this.timeStamp())} ${chalk.grey('[Debug]')}`, content);
+// }
+
+// /**
+// * Logs verbose information. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in grey.
+// * @param content - The content to log, highlights displayed in bright black.
+// */
+// public verbose(header: string, content: string): void {
+// return console.info(`${chalk.bgGrey(this.timeStamp())} ${chalk.grey(`[${header}]`)} ` + this.parseColors(content, 'blackBright'));
+// }
+
+// /**
+// * Logs information. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in cyan.
+// * @param content - The content to log, highlights displayed in bright blue.
+// */
+// public info(header: string, content: string): void {
+// return console.info(`${chalk.bgCyan(this.timeStamp())} ${chalk.cyan(`[${header}]`)} ` + this.parseColors(content, 'blueBright'));
+// }
+
+// /**
+// * Logs warnings. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in yellow.
+// * @param content - The content to log, highlights displayed in bright yellow.
+// */
+// public warn(header: string, content: string): void {
+// return console.warn(`${chalk.bgYellow(this.timeStamp())} ${chalk.yellow(`[${header}]`)} ` + this.parseColors(content, 'yellowBright'));
+// }
+
+// /**
+// * Logs errors. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in bright red.
+// * @param content - The content to log, highlights displayed in bright red.
+// */
+// public error(header: string, content: string): void {
+// return console.error(`${chalk.bgRedBright(this.timeStamp())} ${chalk.redBright(`[${header}]`)} ` + this.parseColors(content, 'redBright'));
+// }
+
+// /**
+// * Logs successes. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in green.
+// * @param content - The content to log, highlights displayed in bright green.
+// */
+// public success(header: string, content: string): void {
+// return console.log(`${chalk.bgGreen(this.timeStamp())} ${chalk.greenBright(`[${header}]`)} ` + this.parseColors(content, 'greenBright'));
+// }
+// }
diff --git a/src/lib/utils/Logger.ts b/src/lib/utils/Logger.ts
index f38365e..96837b6 100644
--- a/src/lib/utils/Logger.ts
+++ b/src/lib/utils/Logger.ts
@@ -1,10 +1,10 @@
import { TextChannel } from 'discord.js';
-import { BotClient } from '../extensions/BotClient';
+import { BushClient } from '../extensions/BushClient';
import chalk from 'chalk';
export class Logger {
- private client: BotClient;
- public constructor(client: BotClient) {
+ private client: BushClient;
+ public constructor(client: BushClient) {
this.client = client;
}
private stripColor(text: string): string {
@@ -15,9 +15,7 @@ export class Logger {
);
}
public getChannel(channel: 'log' | 'error' | 'dm'): Promise<TextChannel> {
- return this.client.channels.fetch(
- this.client.config.channels[channel]
- ) as Promise<TextChannel>;
+ return this.client.channels.fetch(this.client.config.channels[channel]) as Promise<TextChannel>;
}
public async log(message: string, sendChannel = false): Promise<void> {
console.log(chalk`{bgCyan LOG} ` + message);
@@ -28,7 +26,7 @@ export class Logger {
}
public async verbose(message: string, sendChannel = false): Promise<void> {
- if (!this.client.config.verbose) return;
+ if (!this.client.config.logging.verbose) return;
console.log(chalk`{bgMagenta VERBOSE} ` + message);
if (sendChannel) {
const channel = await this.getChannel('log');