From 0966dc2ca37f12e35d80be4ce4ca5875f486f4a1 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Thu, 11 Sep 2025 14:17:55 -0400 Subject: [PATCH 1/2] avoid saying to check DMs when an error isn't DMed --- nomen/notifications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nomen/notifications.py b/nomen/notifications.py index 5f90ddf..f43bd72 100644 --- a/nomen/notifications.py +++ b/nomen/notifications.py @@ -31,7 +31,7 @@ class KeywordError(Exception): async def send(self, ctx): if self.msg: - await ctx.send(self.msg + " (check DMs)") + await ctx.send(self.msg + (" (check DMs)" if self.dm_msg else "")) if self.dm_msg: await ctx.author.send(self.dm_msg) From d8135eb55dda8fc952d57e4dc9a6d0eeefc9bfb1 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Thu, 11 Sep 2025 14:18:37 -0400 Subject: [PATCH 2/2] detect help request with regex --- nomen/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nomen/main.py b/nomen/main.py index 3204e8e..43e9cd6 100644 --- a/nomen/main.py +++ b/nomen/main.py @@ -9,6 +9,7 @@ import traceback from contextlib import redirect_stdout import disnake +import re2 as re from disnake import Embed, Guild, Intents, Message, Thread from disnake.ext import commands from disnake.ext.commands import Bot, Paginator @@ -17,7 +18,7 @@ from dotenv import find_dotenv, load_dotenv from .db import run_db_migrations, setup_db from .notifications import Notifications from .settings import Settings -from .utils import cleanup_code +from .utils import cleanup_code, contains # Logger setup logger_disnake = logging.getLogger("disnake") @@ -228,9 +229,11 @@ async def on_message(message: Message): if now < timeout: return - c = message.content.lower().split(" ") + mentions_nomen = contains(message, "nomen", False) + mentions_help = contains(message, "help", False) + asks_for_help = contains(message, r"how\b(\w+\b)+use\b(\w+\b)*nomen", True) - if "help" in c and "nomen" in c: + if (mentions_nomen and mentions_help) or asks_for_help: help_timeouts[ctx.channel.id] = now + datetime.timedelta(minutes=5) prefix = (await bot.get_guild_prefix(ctx.guild) if ctx.guild else DEFAULT_PREFIX) or "@nomen " await message.reply(f"""\