Browse Source

Separate on_command callback and override it for discord

Kirk Trombley 2 years ago
parent
commit
2b9bc2b5a7
2 changed files with 5 additions and 5 deletions
  1. 3 5
      drivers/discord_driver.py
  2. 2 0
      rollbot/rollbot/bot.py

+ 3 - 5
drivers/discord_driver.py

@@ -36,11 +36,9 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
                 return None
         return cfg
     
-    # async def on_message(self, incoming: discord.Message):
-    #     if incoming.author.bot:
-    #         return await super().on_message(incoming)
-    #     async with incoming.channel.typing():
-    #         return await super().on_message(incoming)
+    async def on_command(self, raw: discord.Message, message: rollbot.Message, command: str):
+        async with raw.channel.typing():
+            return await super().on_command(raw, message, command)
 
     async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Member | discord.User):
         sender_id = getattr(reaction.message.author, "id", None)

+ 2 - 0
rollbot/rollbot/bot.py

@@ -53,7 +53,9 @@ class Rollbot(Generic[RawMsg]):
             return
 
         command = self.command_config.aliases.get(message.command.name, message.command.name)
+        await self.on_command(incoming, message, command)
 
+    async def on_command(self, raw: RawMsg, message: Message, command: str):
         if command == "help":
             args = message.command.args.split(maxsplit=1)
             if len(args) == 0: