diff --git a/src/core/create-plugins.ts b/src/core/create-plugins.ts index 089d5aa..9006b09 100644 --- a/src/core/create-plugins.ts +++ b/src/core/create-plugins.ts @@ -37,6 +37,6 @@ export function CommandControlPlugin( * The object passed into every plugin to control a command's behavior */ export const controller = { - next: (val: unknown=undefined) => Ok(val), + next: (val?: Record) => Ok(val), stop: (val?: string) => Err(val), }; diff --git a/src/core/id.ts b/src/core/id.ts index 3b919c6..3f91f92 100644 --- a/src/core/id.ts +++ b/src/core/id.ts @@ -4,7 +4,7 @@ import { CommandType, EventType } from './structures/enums'; const parseParams = (event: { customId: string }, id: string, append: string) => { const hasSlash = event.customId.indexOf('/') if(hasSlash === -1) { - return { id:id+append }; + return { id:event.customId+append }; } const baseid = event.customId.substring(0, hasSlash); const params = event.customId.substring(hasSlash+1); diff --git a/src/core/module-loading.ts b/src/core/module-loading.ts index dd4ef4f..e4875c5 100644 --- a/src/core/module-loading.ts +++ b/src/core/module-loading.ts @@ -6,7 +6,7 @@ import * as Id from './id' import { Module } from '../types/core-modules'; export const parseCallsite = (site: string) => { - const pathobj = path.parse(site.replace(/file:\\?/, "") + const pathobj = path.posix.parse(site.replace(/file:\\?/, "") .split(path.sep) .join(path.posix.sep)) return { name: pathobj.name, diff --git a/src/types/core-modules.ts b/src/types/core-modules.ts index aeb102d..acf4708 100644 --- a/src/types/core-modules.ts +++ b/src/types/core-modules.ts @@ -193,11 +193,11 @@ type CommandModuleNoPlugins = { [T in CommandType]: Omit; }; type EventModulesNoPlugins = { - [T in EventType]: Omit & { once?: boolean }; + [T in EventType]: Omit ; }; export type InputEvent = { - [T in EventType]: EventModulesNoPlugins[T]; + [T in EventType]: EventModulesNoPlugins[T] & { once?: boolean }; }[EventType]; export type InputCommand = { diff --git a/test/core/module-loading.test.ts b/test/core/module-loading.test.ts index 0f5d790..2ec5633 100644 --- a/test/core/module-loading.test.ts +++ b/test/core/module-loading.test.ts @@ -10,15 +10,28 @@ describe('module-loading', () => { const callsiteinfo = Files.parseCallsite(fname) expect(callsiteinfo.name).toBe("ping") }) - it('should get the filename of the commandmodule (windows, cjs)', () => { - const fname = "C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js" + it('should get filename of commandmodule (linux, cjs)', () => { + const fname = "file:///home/pooba/Projects/sern/halibu/dist/commands/ping.js" const callsiteinfo = Files.parseCallsite(fname) - expect(callsiteinfo.name).toEqual("ping"); + expect(callsiteinfo.name).toBe("ping") + + }) + it('should get the filename of the commandmodule (windows, cjs)', () => { + //this test case is impossible on linux. + if(process.platform == 'win32') { + const fname = "C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js" + const callsiteinfo = Files.parseCallsite(fname) + expect(callsiteinfo.name).toEqual("ping"); + } }) it('should get filename of commandmodule (windows, esm)', () => { - const fname = "file:///C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js" - const callsiteinfo = Files.parseCallsite(fname) - expect(callsiteinfo.name).toEqual("ping"); + //this test case is impossible on linux. + if(process.platform == 'win32') { + const fname = "file:///C:\\pooba\\Projects\\sern\\halibu\\dist\\commands\\ping.js" + const callsiteinfo = Files.parseCallsite(fname) + expect(callsiteinfo.name).toEqual("ping"); + } + }) it('should import a commandModule properly', async () => {