Skip to content

Commit

Permalink
Reload thread cache only when it's the first on_ready trigger. Resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Aug 7, 2021
1 parent 1a885bc commit 3407e05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ v3.10 adds group conversations while resolving othre bugs and QOL changes. It is

- `thread.reply` now returns mod_message, user_message1, user_message2... It is no longer limited at a size 2 tuple. Potentially breaking if plugins depend on this behaviour.
- Fix return types, type hints, and unresolved references ([PR #3009](https://github.com/kyb3r/modmail/pull/3009))
- Reload thread cache only when it's the first on_ready trigger. ([GH #3037](https://github.com/kyb3r/modmail/issues/3037))

# v3.9.5

Expand Down
10 changes: 10 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self):
self.loaded_cogs = ["cogs.modmail", "cogs.plugins", "cogs.utility"]
self._connected = asyncio.Event()
self.start_time = datetime.utcnow()
self._started = False

self.config = ConfigManager(self)
self.config.populate_cache()
Expand Down Expand Up @@ -534,6 +535,13 @@ async def on_ready(self):
logger.error("Logging out due to invalid GUILD_ID.")
return await self.close()

if self._started:
# Bot has started before
logger.line()
logger.warning("Bot restarted due to internal discord reloading.")
logger.line()
return

logger.line()
logger.debug("Client ready.")
logger.info("Logged in as: %s", self.user)
Expand Down Expand Up @@ -634,6 +642,8 @@ async def on_ready(self):
)
logger.warning("If the external servers are valid, you may ignore this message.")

self._started = True

async def convert_emoji(self, name: str) -> str:
ctx = SimpleNamespace(bot=self, guild=self.modmail_guild)
converter = commands.EmojiConverter()
Expand Down

0 comments on commit 3407e05

Please sign in to comment.