diff options
| author | 2022-01-04 13:22:50 -0600 | |
|---|---|---|
| committer | 2022-01-04 19:22:50 +0000 | |
| commit | 3824ddbddff8c3191632c0479f0f594985a55b32 (patch) | |
| tree | 4b32138999244e9560fb4ac408f8f32006dafa7d | |
| parent | Merge pull request #2036 from python-discord/fix-bot-2034 (diff) | |
modlog: wait for guild init before using channel cache
Not doing so could cause an error where get_channel would return none for the mod logs channel.
| -rw-r--r-- | bot/exts/moderation/modlog.py | 3 | 
1 files changed, 3 insertions, 0 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py index 91709e5e5..fc9204998 100644 --- a/bot/exts/moderation/modlog.py +++ b/bot/exts/moderation/modlog.py @@ -96,6 +96,7 @@ class ModLog(Cog, name="ModLog"):          footer: t.Optional[str] = None,      ) -> Context:          """Generate log embed and send to logging channel.""" +        await self.bot.wait_until_guild_available()          # Truncate string directly here to avoid removing newlines          embed = discord.Embed(              description=text[:4093] + "..." if len(text) > 4096 else text @@ -614,6 +615,7 @@ class ModLog(Cog, name="ModLog"):          This is called when a message absent from the cache is deleted.          Hence, the message contents aren't logged.          """ +        await self.bot.wait_until_guild_available()          if self.is_channel_ignored(event.channel_id):              return @@ -727,6 +729,7 @@ class ModLog(Cog, name="ModLog"):      @Cog.listener()      async def on_raw_message_edit(self, event: discord.RawMessageUpdateEvent) -> None:          """Log raw message edit event to message change log.""" +        await self.bot.wait_until_guild_available()          try:              channel = self.bot.get_channel(int(event.data["channel_id"]))              message = await channel.fetch_message(event.message_id)  |