chore: cleanup code and delete unused files

This commit is contained in:
Jacob Nguyen
2022-05-10 00:04:27 -05:00
parent 46b3b9574a
commit 99a5a3c93a
4 changed files with 6 additions and 53 deletions

View File

@@ -1,34 +0,0 @@
export enum sEvent {
GLOBAL_SLASH,
LOCAL_SLASH,
MISUSE_CMD,
DM,
CRASH,
TEXT_CMD,
}
export default class Logger {
public clear() {
console.clear();
}
public log<T extends sEvent>(e: T, guildId: string, message: string) {
// add colored logging?
console.log(`[${new Date().toISOString()}] [${sEvent[e]}] @ ${guildId} :: ${message}`);
}
/**
* Utilizes console.table() to print out memory usage of current process.
* Optional at startup.
*/
public tableRam() {
console.table(
Object.entries(process.memoryUsage())
.map(([k, v]: [string, number]) => {
return { [k]: `${(((Math.round(v) / 1024 / 1024) * 100) / 100).toFixed(2)} MBs` };
})
.reduce((r, c) => Object.assign(r, c), {}),
);
}
}

View File

@@ -1,3 +0,0 @@

View File

@@ -1,15 +1,4 @@
import { ChannelType, Message } from 'discord.js';
/**
* @param message The message object
* @returns `true` if message comes from DM, `false` otherwise
* @example isNotFromDM(message) ? 'Not From DM' : 'from DM'
*
*/
export function isNotFromDM ( message: Message ) {
return message.channel.type !== ChannelType.DM;
}
import type { Message } from 'discord.js';
/**
* Checks if the author of message is a bot or not
@@ -34,7 +23,7 @@ export function hasPrefix(message: Message, prefix?: string) {
}
/**
* Removes the first character(s) _[depending on prefix length]_ of the message
* @param message The message to remove the prefix from
* @param msg
* @param prefix The prefix to remove
* @returns The message without the prefix
* @example

View File

@@ -40,9 +40,9 @@ function readPath(dir: string, arrayOfFiles: string[] = []): string[] {
export const fmtFileName = (n: string) => n.substring(0, n.length - 3);
/**
*
* @param {commandsDir} Relative path to commands directory
* @returns {Promise<{ mod: PluggedModule; absPath: string; }[]>} data from command files
*
* @returns {Observable<{ mod: PluggedModule; absPath: string; }[]>} data from command files
* @param commandDir
*/
export function buildData(commandDir: string ): Observable<
@@ -51,6 +51,7 @@ export function buildData(commandDir: string ): Observable<
absPath: string;
}> {
return from(getCommands(commandDir).map(absPath => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const plugged = (<PluggedModule> require(absPath).module);
return { plugged, absPath };
}));