From fa129efd0cb7ab4273c975c5ed5b560213f432f6 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Sun, 25 Sep 2022 17:59:41 +0200 Subject: [PATCH] Reduce db load for custom commands --- didier/didier.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/didier/didier.py b/didier/didier.py index 0d1671c..06db727 100644 --- a/didier/didier.py +++ b/didier/didier.py @@ -215,9 +215,14 @@ class Didier(commands.Bot): if not message.content.startswith(settings.DISCORD_CUSTOM_COMMAND_PREFIX): return False + # Remove the prefix + content = message.content[len(settings.DISCORD_CUSTOM_COMMAND_PREFIX) :].strip() + + # Message was just "?" (or whatever the prefix was configured to) + if not content: + return False + async with self.postgres_session as session: - # Remove the prefix - content = message.content[len(settings.DISCORD_CUSTOM_COMMAND_PREFIX) :] command = await custom_commands.get_command(session, content) # Command found