Kaynağa Gözat

Support reaction attachments

Kirk Trombley 1 yıl önce
ebeveyn
işleme
d778c895d5
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      drivers/discord_driver.py

+ 6 - 1
drivers/discord_driver.py

@@ -91,6 +91,7 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
         args["content"] = response.text or ""
         attachments = []
         files = []
+        reacts = []
         if response.attachments is not None:
             for att in response.attachments:
                 if att.name == "image":
@@ -107,6 +108,8 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
                     if att.body is None or not isinstance(att.body, str):
                         raise ValueError("Invalid reply body type, must be message ID")
                     args["reference"] = await channel.fetch_message(int(att.body))
+                elif att.name == "react":
+                    reacts.append(att.body)
                 elif isinstance(att.body, discord.Attachment):
                     attachments.append(att.body)
         if len(attachments) > 0:
@@ -114,7 +117,9 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
         if len(files) > 0:
             args["files"] = files
 
-        await channel.send(**args)
+        message = await channel.send(**args)
+        for react in reacts:
+            await message.add_reaction(react)
 
 
 if __name__ == "__main__":