diff --git a/src/core/functions.ts b/src/core/functions.ts index 85cfd8b..18154c7 100644 --- a/src/core/functions.ts +++ b/src/core/functions.ts @@ -1,4 +1,3 @@ -import { Err, Ok } from 'ts-results-es'; import type { Module, SernAutocompleteData, SernOptionsData } from '../types/core-modules'; import type { AnySelectMenuInteraction, @@ -14,6 +13,20 @@ import { PluginType } from './structures/enums'; import assert from 'assert'; import type { Payload } from '../types/utility'; +/** + * Removes the first character(s) _[depending on prefix length]_ of the message + * @param msg + * @param prefix The prefix to remove + * @returns The message without the prefix + * @example + * message.content = '!ping'; + * console.log(fmt(message, '!')); + * // [ 'ping' ] + */ +export function fmt(msg: string, prefix?: string): string[] { + if(!prefix) throw Error("Unable to parse message without prefix"); + return msg.slice(prefix.length).trim().split(/\s+/g); +} export function partitionPlugins diff --git a/src/core/structures/context.ts b/src/core/structures/context.ts index 53069ea..ef3b459 100644 --- a/src/core/structures/context.ts +++ b/src/core/structures/context.ts @@ -12,11 +12,7 @@ import { CoreContext } from '../structures/core-context'; import { Result, Ok, Err } from 'ts-results-es'; import * as assert from 'assert'; import type { ReplyOptions } from '../../types/utility'; - -function fmt(msg: string, prefix?: string): string[] { - if(!prefix) throw Error("Unable to parse message without prefix"); - return msg.slice(prefix.length).trim().split(/\s+/g); -} +import { fmt } from '../functions' /** * @since 1.0.0 diff --git a/src/handlers/event-utils.ts b/src/handlers/event-utils.ts index 0d872a9..21c3f0a 100644 --- a/src/handlers/event-utils.ts +++ b/src/handlers/event-utils.ts @@ -16,7 +16,7 @@ import { CommandType } from '../core/structures/enums' import { inspect } from 'node:util' import { disposeAll } from '../core/ioc/base'; import { arrayifySource, handleError } from '../core/operators'; -import { resultPayload, isAutocomplete, treeSearch } from '../core/functions' +import { resultPayload, isAutocomplete, treeSearch, fmt } from '../core/functions' interface ExecutePayload { module: Module; @@ -88,19 +88,6 @@ function createGenericHandler( concatMap(makeModule)); // create a payload, preparing to execute } -/** - * Removes the first character(s) _[depending on prefix length]_ of the message - * @param msg - * @param prefix The prefix to remove - * @returns The message without the prefix - * @example - * message.content = '!ping'; - * console.log(fmt(message, '!')); - * // [ 'ping' ] - */ -export function fmt(msg: string, prefix: string): string[] { - return msg.slice(prefix.length).trim().split(/\s+/g); -} /** * @@ -137,7 +124,7 @@ export function createInteractionHandler( export function createMessageHandler( source: Observable, defaultPrefix: string, - deps: Dependencies + deps: Dependencies, ) { const mg = deps['@sern/modules']; return createGenericHandler(source, async event => {