mirror of
https://github.com/sern-handler/handler
synced 2026-06-17 21:32:14 +00:00
refactor(utilities): made markup.ts eslint compliant and added formatting to logger
This commit is contained in:
@@ -22,7 +22,7 @@ export default class Logger {
|
||||
dayJS.tz.guess();
|
||||
// add colored logging?
|
||||
const tz = dayJS().format();
|
||||
console.log(`[${tz}][${sEvent[e]}] @ ${guildId} :: ${message}`);
|
||||
console.log(`[${tz}] [${sEvent[e]}] @ ${guildId} :: ${message}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
CommandInteraction,
|
||||
Message
|
||||
} from 'discord.js';
|
||||
|
||||
import { Ok, None, Some } from 'ts-results';
|
||||
import { isNotFromBot, hasPrefix, fmt } from './utilities/messageHelpers';
|
||||
import Logger, { sEvent } from './logger';
|
||||
@@ -43,12 +44,11 @@ export class Handler {
|
||||
**/
|
||||
|
||||
.on('ready', async () => {
|
||||
this.defaultLogger.clear();
|
||||
Files.buildData(this)
|
||||
.then(data => this.registerModules(data));
|
||||
wrapper.init?.(this);
|
||||
this.defaultLogger.tableRam();
|
||||
})
|
||||
|
||||
|
||||
.on('messageCreate', async (message: Message) => {
|
||||
const isExecutable = AllTrue(isNotFromBot, hasPrefix);
|
||||
if (!isExecutable(message, this.prefix)) return;
|
||||
@@ -217,8 +217,7 @@ export class Handler {
|
||||
|
||||
private findModuleFrom<T extends Message | CommandInteraction>(ctx: T): Files.CommandVal | undefined {
|
||||
const name = ctx.applicationId === null ? fmt(ctx as Message, this.prefix).shift()! : (ctx as CommandInteraction).commandName;
|
||||
const posCommand = Files.Commands.get(name) ?? Files.Alias.get(name);
|
||||
return posCommand;
|
||||
return Files.Commands.get(name) ?? Files.Alias.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export module Markup {
|
||||
export enum TimestampStyles {
|
||||
BOTH_LONG = 'F',
|
||||
BOTH_SHORT = 'f',
|
||||
@@ -139,7 +138,7 @@ export module Markup {
|
||||
timestamp: Timestamp
|
||||
) {
|
||||
let ret = FrozenTimestampStyles[using];
|
||||
for (let [key, value] of Object.entries(timestamp)) {
|
||||
for (const [key, value] of Object.entries(timestamp)) {
|
||||
ret = ret.split(`{${key}}`).join(value);
|
||||
}
|
||||
return ret;
|
||||
@@ -148,7 +147,7 @@ export module Markup {
|
||||
const date = new Date(unix);
|
||||
const timestamp = formatDate(date);
|
||||
let ret = FrozenTimestampStyles[style];
|
||||
for (let [key, value] of Object.entries(timestamp)) {
|
||||
for (const [key, value] of Object.entries(timestamp)) {
|
||||
ret = ret.split(`{${key}}`).join(value);
|
||||
}
|
||||
return ret;
|
||||
@@ -248,7 +247,7 @@ export module Markup {
|
||||
static timestamp(
|
||||
unix: number | Date | string,
|
||||
format: TimestampStyles = TimestampStyles.BOTH_SHORT,
|
||||
isSeconds: boolean = false
|
||||
isSeconds = false
|
||||
) {
|
||||
if (typeof unix === 'string') unix = Number(unix);
|
||||
if (unix instanceof Date) unix = unix.getTime();
|
||||
@@ -262,7 +261,7 @@ export module Markup {
|
||||
static date(
|
||||
unix: number | Date | string,
|
||||
format: TimestampStyles = TimestampStyles.BOTH_SHORT,
|
||||
isSeconds: boolean = false
|
||||
isSeconds = false
|
||||
) {
|
||||
if (typeof unix === 'string') unix = Number(unix);
|
||||
if (unix instanceof Date) unix = unix.getTime();
|
||||
@@ -423,7 +422,7 @@ export module Markup {
|
||||
|
||||
match<T extends DiscordRegexMatch>(
|
||||
type: DiscordRegexNames,
|
||||
onlyFirst: boolean = false
|
||||
onlyFirst = false
|
||||
): DiscordRegexPayload<T> {
|
||||
const regex = DiscordRegex[type];
|
||||
if (regex === undefined) {
|
||||
@@ -529,7 +528,7 @@ export module Markup {
|
||||
static match(
|
||||
raw: string,
|
||||
what: DiscordRegexNames,
|
||||
onlyFirst: boolean = false
|
||||
onlyFirst = false
|
||||
) {
|
||||
return new this(raw).match(what, onlyFirst);
|
||||
}
|
||||
@@ -558,4 +557,3 @@ export module Markup {
|
||||
return new this(raw).url();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user