some bug fixes

This commit is contained in:
jacoobes
2022-01-25 16:45:21 -06:00
parent e2ee5fa1bf
commit 8118a88522
5 changed files with 10 additions and 10 deletions

4
package-lock.json generated
View File

@@ -1,11 +1,11 @@
{
"name": "sernhandler2",
"name": "@jacoobes/sern",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "sernhandler2",
"name": "@jacoobes/sern",
"version": "1.0.0",
"license": "ISC",
"dependencies": {

View File

@@ -1,5 +1,5 @@
{
"name": "@jacoobes/sern",
"name": "sernhandler2",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",

View File

@@ -3,7 +3,7 @@ import { CommandType } from "../../types/handler/handler";
import { Files } from "../utils/readFile"
import type { Awaitable, Client, Message } from "discord.js";
import type { possibleOutput } from "../../types/handler/handler"
import { Ok, Result } from "ts-results";
import { Err, Ok, Result } from "ts-results";
@@ -25,7 +25,7 @@ export namespace Sern {
.on("messageCreate", async message => {
let tryFmt = this.msgHandler.listen({message, prefix: this.prefix}).fmt();
if (tryFmt === undefined) return;
if (tryFmt.err) return;
const commandName = this.msgHandler.fmtMsg!.shift()!;
const module = Files.Commands.get(commandName) ?? Files.Alias.get(commandName)
let cmdResult = (await this.commandResult(module, message))
@@ -60,7 +60,7 @@ export namespace Sern {
}
export interface Wrapper {
client : Client<boolean>,
client : Client,
prefix: string,
commands : string
init? : () => void,
@@ -92,9 +92,10 @@ class MsgHandler {
return this.message.author.bot || msg.slice(0, this.prefix.length).toLowerCase() !== this.prefix;
}
fmt() : void | undefined {
if (this.isCommand()) return undefined;
fmt() : Result<void, void> {
if (this.isCommand()) return Err(void 0);
this.resMsg = this.message.content.slice(this.prefix.length).trim().split(/\s+/g);
return Ok(void 0);
}
get fmtMsg() {

View File

@@ -25,7 +25,6 @@ export namespace Files {
}
export async function registerModules(dir: string) : Promise<void> {
Promise.all((await getCommands(dir)).map(async absPath => {
return { name : basename(absPath), mod: ( await import(absPath)).default as Sern.Module<unknown> }
})).then( modArr => {

View File

@@ -1,4 +1,4 @@
import { Sern } from "./handler/sern/sern";
exports = Sern;
module.exports = Sern;
export default Sern;