diff --git a/redbot/__main__.py b/redbot/__main__.py index 635ef7f15..d32e7fd3b 100644 --- a/redbot/__main__.py +++ b/redbot/__main__.py @@ -17,7 +17,7 @@ import sys from argparse import Namespace from copy import deepcopy from pathlib import Path -from typing import Any, Awaitable, Callable, NoReturn, Union +from typing import Any, Awaitable, Callable, NoReturn, Optional, Union import discord import rich @@ -62,9 +62,9 @@ def list_instances(): sys.exit(ExitCodes.SHUTDOWN) -async def debug_info(*args: Any) -> None: +async def debug_info(red: Optional[Red] = None, *args: Any) -> None: """Shows debug information useful for debugging.""" - print(await DebugInfo().get_text()) + print(await DebugInfo(red).get_cli_text()) async def edit_instance(red, cli_flags): diff --git a/redbot/core/_debuginfo.py b/redbot/core/_debuginfo.py index 7cc5ffb4b..da9230121 100644 --- a/redbot/core/_debuginfo.py +++ b/redbot/core/_debuginfo.py @@ -50,11 +50,13 @@ class DebugInfo: def __init__(self, bot: Optional[Red] = None) -> None: self.bot = bot - async def get_text(self) -> str: - if self.bot is None: - return await self.get_cli_text() - else: - return await self.get_command_text() + @property + def is_logged_in(self) -> bool: + return self.bot is not None and self.bot.application_id is not None + + @property + def is_connected(self) -> bool: + return self.bot is not None and self.bot.is_ready() async def get_cli_text(self) -> str: parts = ["\x1b[31m# Debug Info for Red:\x1b[0m"] @@ -139,7 +141,14 @@ class DebugInfo: ) parts = [f"Instance name: {instance_name}"] + if self.bot is not None: + # This formatting is a bit ugly but this is a debug information command + # and calling repr() on prefix strings ensures that the list isn't ambiguous. + prefixes = ", ".join(map(repr, await self.bot._config.prefix())) + parts.append(f"Global prefix(es): {prefixes}") + + if self.is_logged_in: owners = [] for uid in self.bot.owner_ids: try: @@ -150,7 +159,7 @@ class DebugInfo: owners_string = ", ".join(owners) or "None" parts.append(f"Owner(s): {', '.join(owners) or 'None'}") - if self.bot is not None: + if self.is_connected: disabled_intents = ( ", ".join( intent_name.replace("_", " ").title() diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 47188e37c..6b610cfbc 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -4688,7 +4688,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): """Shows debug information useful for debugging.""" from redbot.core._debuginfo import DebugInfo - await ctx.send(await DebugInfo(self.bot).get_text()) + await ctx.send(await DebugInfo(self.bot).get_command_text()) # You may ask why this command is owner-only, # cause after all it could be quite useful to guild owners!