From 6cd71bbf31afa303e146fb123bb96be25e170dde Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Mon, 5 Jul 2021 20:53:41 +0200 Subject: [PATCH] simplified export --- src/Bot.ts | 4 ++-- src/Command.ts | 23 ++++++++++------------- src/Help.ts | 6 ++---- src/SystemMessage.ts | 8 +++----- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/Bot.ts b/src/Bot.ts index d476b6b..0f7ea8f 100644 --- a/src/Bot.ts +++ b/src/Bot.ts @@ -26,7 +26,7 @@ interface ConstructorOptions { } //MAIN CLASS -class Bot extends EventEmitter { +export class Bot extends EventEmitter { name: string; client: Client; commands: CommandManager; @@ -114,6 +114,7 @@ class Bot extends EventEmitter { try { await cmdMsg.command.start(m, cmdMsg.arguments); } catch (e) { + this.emit("error", [e]); if (e instanceof PermissionsError) { this.messages.system.send( "PERMISSION", @@ -160,4 +161,3 @@ class Bot extends EventEmitter { //EXPORTS export default Bot; -export { Bot, Command }; diff --git a/src/Command.ts b/src/Command.ts index 6e47be1..c7d300d 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -8,6 +8,13 @@ import { } from "discord.js"; //TYPE DEFINITIONS +type GetMode = "ALL" | "PREFIX" | "NO_PREFIX"; +type PermissionCheckTypes = "ALL" | "ANY"; +export interface CommandMessageStructure { + name: string; + arguments: string[]; + command: Command | null; +} interface CommandBuilder { name: string; aliases?: string[] | string; @@ -22,20 +29,13 @@ interface CommandBuilder { cmdArguments?: string[] ) => void | string | MessageEmbed | Promise; } -interface CommandMessageStructure { - name: string; - arguments: string[]; - command: Command | null; -} interface PhraseOccurrenceData { command: Command; type: "NAME" | "ALIAS"; } -type GetMode = "ALL" | "PREFIX" | "NO_PREFIX"; -type PermissionCheckTypes = "ALL" | "ANY"; //ERROR CLASSES -class PermissionsError { +export class PermissionsError { private command: Command; private user: GuildMember | null; constructor(command: Command, user?: GuildMember | null) { @@ -48,7 +48,7 @@ class PermissionsError { } //CLASSES -class Command { +export class Command { name: string; aliases: string[]; keywords: string[]; @@ -137,7 +137,7 @@ class Command { } } } -class CommandManager { +export class CommandManager { list: Command[]; prefix: string; argumentSeparator: string; @@ -317,6 +317,3 @@ class CommandManager { return returnValue; } } - -//EXPORTS -export { Command, CommandManager, CommandMessageStructure, PermissionsError }; diff --git a/src/Help.ts b/src/Help.ts index a0729d2..3bf845d 100644 --- a/src/Help.ts +++ b/src/Help.ts @@ -1,7 +1,7 @@ import { ColorResolvable, MessageEmbed } from "discord.js"; import { Command, CommandManager } from "./Command.js"; -interface HelpMessageParams { +export interface HelpMessageParams { title: string; bottomText: string; color: ColorResolvable; @@ -9,7 +9,7 @@ interface HelpMessageParams { usage: string; } -class HelpMessage extends Command { +export class HelpMessage extends Command { constructor( cmdManager: CommandManager, params: HelpMessageParams, @@ -89,5 +89,3 @@ class HelpMessage extends Command { }); } } - -export { HelpMessage, HelpMessageParams }; diff --git a/src/SystemMessage.ts b/src/SystemMessage.ts index 57b9806..ae56a98 100644 --- a/src/SystemMessage.ts +++ b/src/SystemMessage.ts @@ -10,8 +10,8 @@ import { } from "discord.js"; import { Command, PermissionsError } from "./Command.js"; -type MessageType = "PERMISSION" | "ERROR" | "NOT_FOUND"; -interface SystemMessageAppearance { +export type MessageType = "PERMISSION" | "ERROR" | "NOT_FOUND"; +export interface SystemMessageAppearance { title: string; bottomText?: string; accentColor?: ColorResolvable; @@ -25,7 +25,7 @@ interface SystemMessageData { error?: Error | PermissionsError | string; } -class SystemMessageManager { +export class SystemMessageManager { enabled: boolean; PERMISSION: SystemMessageAppearance; ERROR: SystemMessageAppearance; @@ -167,5 +167,3 @@ class SystemMessageManager { } } } - -export { MessageType, SystemMessageAppearance, SystemMessageManager };