From 5f7f1ced017582d4d09123cf5a70a60b2e5624b5 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Thu, 19 Oct 2023 21:20:20 +0530 Subject: [PATCH] Match dice for full line optionally as a command --- commands/dice.js | 8 ++++---- commands/index.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/dice.js b/commands/dice.js index 5977702..8570faa 100644 --- a/commands/dice.js +++ b/commands/dice.js @@ -15,13 +15,13 @@ module.exports = () => async (ctx) => { .map((i) => `_You roll a_ *D${diceSides}* _and get a_ *${i}*`) .join("\n"); let totalMessage = ""; - if (numDice > 1 || ctx.match[3]) + if (numDice > 1 || ctx.match[4]) totalMessage = `*Total:* ${total}`; - if (ctx.match[3]) { + if (ctx.match[4]) { - const modifier = parseInt(ctx.match[5]); - const sign = ctx.match[4]; + const modifier = parseInt(ctx.match[6]); + const sign = ctx.match[5]; if (sign === "+") totalMessage += ` + ${modifier} = ${total + modifier}`; else totalMessage += ` - ${modifier} = ${total - modifier}`; diff --git a/commands/index.js b/commands/index.js index e9536be..af8427c 100644 --- a/commands/index.js +++ b/commands/index.js @@ -70,7 +70,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay bot.command("donate", (ctx) => ctx.reply("Thanks for considering to donate." + " To support the development and hosting of Quadnite Bot, you can " + "donate here: https://liberapay.com/ceda_ei/")); - bot.hears(/(\d*)d(\d+)(\s*([-+])\s*(\d+))?/i, dice()); + bot.hears(/^\/?(\d*)d(\d+)(@\w+)?(\s*([-+])\s*(\d+))?$/i, dice()); function getGetGif(command) {