mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 10:12:14 +00:00
chore: cleanup code and delete unused files
This commit is contained in:
@@ -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), {}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 };
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user