aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/__init__.py6
-rw-r--r--bot/__main__.py7
2 files changed, 10 insertions, 3 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index 3ee70c4e9..0642b2c5d 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -5,12 +5,16 @@ import sys
from functools import partial, partialmethod
from logging import Logger, handlers
from pathlib import Path
+from typing import TYPE_CHECKING
import coloredlogs
from discord.ext import commands
from bot.command import Command
+if TYPE_CHECKING:
+ from bot.bot import Bot
+
TRACE_LEVEL = logging.TRACE = 5
logging.addLevelName(TRACE_LEVEL, "TRACE")
@@ -76,3 +80,5 @@ if os.name == "nt":
# Must be patched before any cogs are added.
commands.command = partial(commands.command, cls=Command)
commands.GroupMixin.command = partialmethod(commands.GroupMixin.command, cls=Command)
+
+instance: "Bot" = None # Global Bot instance.
diff --git a/bot/__main__.py b/bot/__main__.py
index 367be1300..9d48c9092 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -9,6 +9,7 @@ from sentry_sdk.integrations.aiohttp import AioHttpIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.redis import RedisIntegration
+import bot
from bot import constants
from bot.bot import Bot
from bot.utils.extensions import EXTENSIONS
@@ -54,7 +55,7 @@ intents.dm_reactions = False
intents.invites = False
intents.webhooks = False
intents.integrations = False
-bot = Bot(
+bot.instance = Bot(
redis_session=redis_session,
loop=loop,
command_prefix=when_mentioned_or(constants.Bot.prefix),
@@ -71,6 +72,6 @@ if not constants.HelpChannels.enable:
extensions.remove("bot.exts.help_channels")
for extension in extensions:
- bot.load_extension(extension)
+ bot.instance.load_extension(extension)
-bot.run(constants.Bot.token)
+bot.instance.run(constants.Bot.token)