mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Add global prefixes to debuginfo (#6153)
This commit is contained in:
parent
2386b8363f
commit
a2132ad0a5
@ -17,7 +17,7 @@ import sys
|
|||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Awaitable, Callable, NoReturn, Union
|
from typing import Any, Awaitable, Callable, NoReturn, Optional, Union
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import rich
|
import rich
|
||||||
@ -62,9 +62,9 @@ def list_instances():
|
|||||||
sys.exit(ExitCodes.SHUTDOWN)
|
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."""
|
"""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):
|
async def edit_instance(red, cli_flags):
|
||||||
|
|||||||
@ -50,11 +50,13 @@ class DebugInfo:
|
|||||||
def __init__(self, bot: Optional[Red] = None) -> None:
|
def __init__(self, bot: Optional[Red] = None) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
async def get_text(self) -> str:
|
@property
|
||||||
if self.bot is None:
|
def is_logged_in(self) -> bool:
|
||||||
return await self.get_cli_text()
|
return self.bot is not None and self.bot.application_id is not None
|
||||||
else:
|
|
||||||
return await self.get_command_text()
|
@property
|
||||||
|
def is_connected(self) -> bool:
|
||||||
|
return self.bot is not None and self.bot.is_ready()
|
||||||
|
|
||||||
async def get_cli_text(self) -> str:
|
async def get_cli_text(self) -> str:
|
||||||
parts = ["\x1b[31m# Debug Info for Red:\x1b[0m"]
|
parts = ["\x1b[31m# Debug Info for Red:\x1b[0m"]
|
||||||
@ -139,7 +141,14 @@ class DebugInfo:
|
|||||||
)
|
)
|
||||||
|
|
||||||
parts = [f"Instance name: {instance_name}"]
|
parts = [f"Instance name: {instance_name}"]
|
||||||
|
|
||||||
if self.bot is not None:
|
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 = []
|
owners = []
|
||||||
for uid in self.bot.owner_ids:
|
for uid in self.bot.owner_ids:
|
||||||
try:
|
try:
|
||||||
@ -150,7 +159,7 @@ class DebugInfo:
|
|||||||
owners_string = ", ".join(owners) or "None"
|
owners_string = ", ".join(owners) or "None"
|
||||||
parts.append(f"Owner(s): {', '.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 = (
|
disabled_intents = (
|
||||||
", ".join(
|
", ".join(
|
||||||
intent_name.replace("_", " ").title()
|
intent_name.replace("_", " ").title()
|
||||||
|
|||||||
@ -4688,7 +4688,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
"""Shows debug information useful for debugging."""
|
"""Shows debug information useful for debugging."""
|
||||||
from redbot.core._debuginfo import DebugInfo
|
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,
|
# You may ask why this command is owner-only,
|
||||||
# cause after all it could be quite useful to guild owners!
|
# cause after all it could be quite useful to guild owners!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user