consolidate fmt

This commit is contained in:
Jacob Nguyen
2024-05-23 22:00:12 -05:00
parent 76d9db7b98
commit af0f909c44
3 changed files with 17 additions and 21 deletions

View File

@@ -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<T,V>

View File

@@ -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