From 6d3f511807082dcdbe72bb0a00742a3f70a5e07e Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Sat, 30 Dec 2023 17:33:59 +0700 Subject: [PATCH] use regexp for /roll matching --- src/commands/roll.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands/roll.ts b/src/commands/roll.ts index 7f3c526..90fd372 100644 --- a/src/commands/roll.ts +++ b/src/commands/roll.ts @@ -86,9 +86,8 @@ const getRoute = async ( export const roll = async (text: string) => { try { - const parts = text.trim().split(" "); - - const result = await getRoute(parseVal(parts[1]), parseVal(parts[2])); + const parts = text.match(/^\/roll\s?(\d+)?[-\s]?(\d+)?$/); + const result = await getRoute(parseVal(parts?.[1]), parseVal(parts?.[2])); if (!result || !result?.id) { return say(failureMessages);