1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-24 22:46:41 +07:00

use regexp for /roll matching

This commit is contained in:
Fedor Katurov 2023-12-30 17:33:59 +07:00
parent b2c7728d06
commit 6d3f511807

View file

@ -86,9 +86,8 @@ const getRoute = async (
export const roll = async (text: string) => { export const roll = async (text: string) => {
try { try {
const parts = text.trim().split(" "); const parts = text.match(/^\/roll\s?(\d+)?[-\s]?(\d+)?$/);
const result = await getRoute(parseVal(parts?.[1]), parseVal(parts?.[2]));
const result = await getRoute(parseVal(parts[1]), parseVal(parts[2]));
if (!result || !result?.id) { if (!result || !result?.id) {
return say(failureMessages); return say(failureMessages);