Skip to content

Commit 0676dea

Browse files
authored
Moves the modmail config check to setup (#980)
Moves the check if modmail is disabled to the setup function to prevent the modmail bot from trying to load at all
1 parent d2f96cc commit 0676dea

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

techsupport_bot/commands/modmail.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,13 @@ async def log_closure(
811811

812812
async def setup(bot):
813813
"""Sets the modmail extension up"""
814+
815+
# Only runs if modmail is enabled
816+
if not bot.file_config.modmail_config.enable_modmail:
817+
# Raising an exception makes the extension loading mark as failed, this is surprisingly
818+
# the most reliable way to ensure the modmail bot or code doesn't run
819+
raise AttributeError("Modmail was not loaded because it's disabled")
820+
814821
config = extensionconfig.ExtensionConfig()
815822

816823
config.add(
@@ -867,12 +874,6 @@ def __init__(self: Self, bot: bot.TechSupportBot):
867874
# Init is used to make variables global so they can be used on the modmail side
868875
super().__init__(bot=bot)
869876

870-
# Only runs if modmail is enabled
871-
if not bot.file_config.modmail_config.enable_modmail:
872-
# Raising an exception makes the extension loading mark as failed, this is surprisingly
873-
# the most reliable way to ensure the modmail bot or code doesn't run
874-
raise AttributeError("Modmail was not loaded because it's disabled")
875-
876877
# Makes the TS client available globally for creating threads and populating them with info
877878
# pylint: disable=W0603
878879
global Ts_client

0 commit comments

Comments
 (0)