diff --git a/commands/utils.py b/commands/utils.py index 19e11ef..a7d8265 100644 --- a/commands/utils.py +++ b/commands/utils.py @@ -55,14 +55,17 @@ def match(command: str) -> list[Command] | None: @lru_cache -def tokenize(string: str) -> list[str]: +def tokenize(string: str, remove_prefix: bool = True) -> list[str]: tokens = [] token = "" in_quotes = False quote_char = None escape = False - for char in string[len(constants.PREFIX) :]: + if remove_prefix: + string = string[len(constants.PREFIX) :] + + for char in string: if escape: token += char escape = False diff --git a/fun.py b/fun.py index b3cfd52..1cf25e4 100644 --- a/fun.py +++ b/fun.py @@ -1,7 +1,9 @@ import random +import commands + async def on_message(message): - if "gn" in message.content: + if "gn" in commands.tokenize(message.content, remove_prefix=False): if random.random() < 0.01: await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"]))