Skip to content

Commit

Permalink
Fix genesis message retrieval failure
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed Jul 9, 2023
1 parent 5692500 commit f2804ca
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ async def from_channel(cls, manager: "ThreadManager", channel: discord.TextChann
return thread

async def get_genesis_message(self) -> discord.Message:
if self._genesis_message is None:
async for m in self.channel.history(limit=5, oldest_first=True):
if m.author == self.bot.user:
if m.embeds and m.embeds[0].fields and m.embeds[0].fields[0].name == "Roles":
self._genesis_message = m

if isinstance(self._genesis_message, discord.Message):
return self._genesis_message
# TODO: Store genesis message in db and use manual detection for last resort
async for m in self.channel.history(limit=5, oldest_first=True):
if (
m.author == self.bot.user
and isinstance(m.embeds, list)
and m.embeds[0]
and m.embeds[0].footer
and "user id:" in m.embeds[0].footer.text.lower()
):
self._genesis_message = m
return self._genesis_message

async def setup(self, *, creator=None, category=None, initial_message=None):
Expand Down

0 comments on commit f2804ca

Please sign in to comment.