simplified export

This commit is contained in:
mmacierzanka committed 2021-07-05 20:53:41 +02:00
1 parent 2ceb32e186
commit 6cd71bbf31
4 files changed
+17 -24

No files matched your search

+2 -2
View File
@@ -26,7 +26,7 @@ interface ConstructorOptions {
} }
//MAIN CLASS //MAIN CLASS
class Bot extends EventEmitter { export class Bot extends EventEmitter {
name: string; name: string;
client: Client; client: Client;
commands: CommandManager; commands: CommandManager;
@@ -114,6 +114,7 @@ class Bot extends EventEmitter {
try { try {
await cmdMsg.command.start(m, cmdMsg.arguments); await cmdMsg.command.start(m, cmdMsg.arguments);
} catch (e) { } catch (e) {
this.emit("error", [e]);
if (e instanceof PermissionsError) { if (e instanceof PermissionsError) {
this.messages.system.send( this.messages.system.send(
"PERMISSION", "PERMISSION",
@@ -160,4 +161,3 @@ class Bot extends EventEmitter {
//EXPORTS //EXPORTS
export default Bot; export default Bot;
export { Bot, Command };
+10 -13
View File
@@ -8,6 +8,13 @@ import {
} from "discord.js"; } from "discord.js";
//TYPE DEFINITIONS //TYPE DEFINITIONS
type GetMode = "ALL" | "PREFIX" | "NO_PREFIX";
type PermissionCheckTypes = "ALL" | "ANY";
export interface CommandMessageStructure {
name: string;
arguments: string[];
command: Command | null;
}
interface CommandBuilder { interface CommandBuilder {
name: string; name: string;
aliases?: string[] | string; aliases?: string[] | string;
@@ -22,20 +29,13 @@ interface CommandBuilder {
cmdArguments?: string[] cmdArguments?: string[]
) => void | string | MessageEmbed | Promise<void | string | MessageEmbed>; ) => void | string | MessageEmbed | Promise<void | string | MessageEmbed>;
} }
interface CommandMessageStructure {
name: string;
arguments: string[];
command: Command | null;
}
interface PhraseOccurrenceData { interface PhraseOccurrenceData {
command: Command; command: Command;
type: "NAME" | "ALIAS"; type: "NAME" | "ALIAS";
} }
type GetMode = "ALL" | "PREFIX" | "NO_PREFIX";
type PermissionCheckTypes = "ALL" | "ANY";
//ERROR CLASSES //ERROR CLASSES
class PermissionsError { export class PermissionsError {
private command: Command; private command: Command;
private user: GuildMember | null; private user: GuildMember | null;
constructor(command: Command, user?: GuildMember | null) { constructor(command: Command, user?: GuildMember | null) {
@@ -48,7 +48,7 @@ class PermissionsError {
} }
//CLASSES //CLASSES
class Command { export class Command {
name: string; name: string;
aliases: string[]; aliases: string[];
keywords: string[]; keywords: string[];
@@ -137,7 +137,7 @@ class Command {
} }
} }
} }
class CommandManager { export class CommandManager {
list: Command[]; list: Command[];
prefix: string; prefix: string;
argumentSeparator: string; argumentSeparator: string;
@@ -317,6 +317,3 @@ class CommandManager {
return returnValue; return returnValue;
} }
} }
//EXPORTS
export { Command, CommandManager, CommandMessageStructure, PermissionsError };
+2 -4
View File
@@ -1,7 +1,7 @@
import { ColorResolvable, MessageEmbed } from "discord.js"; import { ColorResolvable, MessageEmbed } from "discord.js";
import { Command, CommandManager } from "./Command.js"; import { Command, CommandManager } from "./Command.js";
interface HelpMessageParams { export interface HelpMessageParams {
title: string; title: string;
bottomText: string; bottomText: string;
color: ColorResolvable; color: ColorResolvable;
@@ -9,7 +9,7 @@ interface HelpMessageParams {
usage: string; usage: string;
} }
class HelpMessage extends Command { export class HelpMessage extends Command {
constructor( constructor(
cmdManager: CommandManager, cmdManager: CommandManager,
params: HelpMessageParams, params: HelpMessageParams,
@@ -89,5 +89,3 @@ class HelpMessage extends Command {
}); });
} }
} }
export { HelpMessage, HelpMessageParams };
+3 -5
View File
@@ -10,8 +10,8 @@ import {
} from "discord.js"; } from "discord.js";
import { Command, PermissionsError } from "./Command.js"; import { Command, PermissionsError } from "./Command.js";
type MessageType = "PERMISSION" | "ERROR" | "NOT_FOUND"; export type MessageType = "PERMISSION" | "ERROR" | "NOT_FOUND";
interface SystemMessageAppearance { export interface SystemMessageAppearance {
title: string; title: string;
bottomText?: string; bottomText?: string;
accentColor?: ColorResolvable; accentColor?: ColorResolvable;
@@ -25,7 +25,7 @@ interface SystemMessageData {
error?: Error | PermissionsError | string; error?: Error | PermissionsError | string;
} }
class SystemMessageManager { export class SystemMessageManager {
enabled: boolean; enabled: boolean;
PERMISSION: SystemMessageAppearance; PERMISSION: SystemMessageAppearance;
ERROR: SystemMessageAppearance; ERROR: SystemMessageAppearance;
@@ -167,5 +167,3 @@ class SystemMessageManager {
} }
} }
} }
export { MessageType, SystemMessageAppearance, SystemMessageManager };