mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
make the command parser nicer, fix the cheer parser
This commit is contained in:
@@ -2,15 +2,17 @@ import { commandPrefix } from "..";
|
|||||||
|
|
||||||
/** Helper function to extract arguments from commands */
|
/** Helper function to extract arguments from commands */
|
||||||
export default function parseCommandArgs(input: string) {
|
export default function parseCommandArgs(input: string) {
|
||||||
const a = input.slice(commandPrefix.length);
|
const nice = input.toLowerCase().slice(commandPrefix.length).trim();
|
||||||
const sliceLength = a.startsWith('use') ? 2 : 1;
|
const sliceLength = nice.startsWith('use') ? 2 : 1;
|
||||||
const b = a.trim().split(' ').slice(sliceLength);
|
return nice.split(' ').slice(sliceLength);
|
||||||
return b;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parseCheerArgs(input: string) {
|
export function parseCheerArgs(input: string) {
|
||||||
const a = input.slice(commandPrefix.length);
|
const nice = input.toLowerCase().trim();
|
||||||
const sliceLength = a.startsWith('testcheer') ? 2 : 0;
|
|
||||||
const b = a.trim().split(' ').slice(sliceLength);
|
// This is for the test command. Remove the command prefix, the command, the whitespace after and the amount of fake bits
|
||||||
return b;
|
if (nice.startsWith(commandPrefix + 'testcheer')) return nice.slice(commandPrefix.length + 'testcheer'.length + 1).split(' ').slice(1);
|
||||||
|
|
||||||
|
// This is for actual cheers. Remove all 'cheerx' parts of the message
|
||||||
|
return nice.split(' ').filter(a => !/cheer[0-9]+/.test(a));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user