From 397c579a27b0d71a6c7b03309de8a2bc73ddb0ea Mon Sep 17 00:00:00 2001 From: git-bruh Date: Thu, 21 Jan 2021 12:50:58 +0530 Subject: [PATCH] update --- README.md | 2 ++ use_client_emojis.patch | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 use_client_emojis.patch diff --git a/README.md b/README.md index d23b4f8..64423c4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ A simple non-puppeting bridge between Matrix and Discord written in Python. * Normal Discord bot functionality like commands can be added to the bot via [cogs](https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html), example [here](https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be). +* Apply `use_client_emojis.patch` to make the Discord bot use emojis from all it's servers. + NOTE: [Privileged Intents](https://discordpy.readthedocs.io/en/latest/intents.html#privileged-intents) must be enabled for your Discord bot. ## What Works diff --git a/use_client_emojis.patch b/use_client_emojis.patch new file mode 100644 index 0000000..fa8cad0 --- /dev/null +++ b/use_client_emojis.patch @@ -0,0 +1,35 @@ +diff --git a/main.py b/main.py +index 53dc289..9acbb43 100644 +--- a/main.py ++++ b/main.py +@@ -56,7 +56,7 @@ class MatrixClient(nio.AsyncClient): + await self.sync(timeout) + + # Set up event callbacks +- callbacks = Callbacks(self) ++ callbacks = Callbacks(self, discord_client) + + self.add_event_callback( + callbacks.message_callback, +@@ -320,8 +320,9 @@ class DiscordClient(discord.ext.commands.Bot): + + + class Callbacks(object): +- def __init__(self, matrix_client): ++ def __init__(self, matrix_client, discord_client): + self.matrix_client = matrix_client ++ self.discord_client = discord_client + + def get_channel(self, room): + channel_id = next( +@@ -450,7 +451,9 @@ class Callbacks(object): + for emote in emotes: + if emote not in added_emotes: + added_emotes.append(emote) +- emote_ = discord.utils.get(guild.emojis, name=emote) ++ emote_ = discord.utils.get( ++ self.discord_client.emojis, name=emote ++ ) + if emote_: + message = message.replace(f":{emote}:", str(emote_)) +