mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
some bug fixes
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@jacoobes/sern",
|
||||
"name": "sernhandler2",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Sern } from "./handler/sern/sern";
|
||||
|
||||
exports = Sern;
|
||||
module.exports = Sern;
|
||||
export default Sern;
|
||||
Reference in New Issue
Block a user