Reduce db load for custom commands

pull/136/head
stijndcl 2022-09-25 17:59:41 +02:00
parent 5f72701714
commit fa129efd0c
1 changed files with 7 additions and 2 deletions

View File

@ -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