mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
Use correct prefixes when sending messages to owners (#3632)
* use correct prefixes when sending messages to owners * make internal util for this instead * oops * fix circular import * let's add back the actual fix I made this PR for... * fix wrong logger name * improve log message
This commit is contained in:
@@ -43,11 +43,12 @@ from .settings_caches import PrefixManager, IgnoreManager, WhitelistBlacklistMan
|
||||
|
||||
from .rpc import RPCMixin
|
||||
from .utils import common_filters
|
||||
from .utils._internal_utils import send_to_owners_with_prefix_replaced
|
||||
|
||||
CUSTOM_GROUPS = "CUSTOM_GROUPS"
|
||||
SHARED_API_TOKENS = "SHARED_API_TOKENS"
|
||||
|
||||
log = logging.getLogger("redbot")
|
||||
log = logging.getLogger("red")
|
||||
|
||||
__all__ = ["RedBase", "Red", "ExitCodes"]
|
||||
|
||||
@@ -548,18 +549,6 @@ class RedBase(
|
||||
|
||||
last_system_info = await self._config.last_system_info()
|
||||
|
||||
async def notify_owners(content: str) -> None:
|
||||
destinations = await self.get_owner_notification_destinations()
|
||||
for destination in destinations:
|
||||
prefixes = await self.get_valid_prefixes(getattr(destination, "guild", None))
|
||||
prefix = re.sub(rf"<@!?{self.bot.user.id}>", f"@{self.bot.user.name}", prefixes[0])
|
||||
try:
|
||||
await destination.send(content.format(prefix=prefix))
|
||||
except Exception as _exc:
|
||||
log.exception(
|
||||
f"I could not send an owner notification to ({destination.id}){destination}"
|
||||
)
|
||||
|
||||
ver_info = list(sys.version_info[:2])
|
||||
python_version_changed = False
|
||||
LIB_PATH = cog_data_path(raw_name="Downloader") / "lib"
|
||||
@@ -569,13 +558,14 @@ class RedBase(
|
||||
shutil.rmtree(str(LIB_PATH))
|
||||
LIB_PATH.mkdir()
|
||||
self.loop.create_task(
|
||||
notify_owners(
|
||||
send_to_owners_with_prefix_replaced(
|
||||
self,
|
||||
"We detected a change in minor Python version"
|
||||
" and cleared packages in lib folder.\n"
|
||||
"The instance was started with no cogs, please load Downloader"
|
||||
" and use `{prefix}cog reinstallreqs` to regenerate lib folder."
|
||||
" and use `[p]cog reinstallreqs` to regenerate lib folder."
|
||||
" After that, restart the bot to get"
|
||||
" all of your previously loaded cogs loaded again."
|
||||
" all of your previously loaded cogs loaded again.",
|
||||
)
|
||||
)
|
||||
python_version_changed = True
|
||||
@@ -603,11 +593,12 @@ class RedBase(
|
||||
|
||||
if system_changed and not python_version_changed:
|
||||
self.loop.create_task(
|
||||
notify_owners(
|
||||
send_to_owners_with_prefix_replaced(
|
||||
self,
|
||||
"We detected a possible change in machine's operating system"
|
||||
" or architecture. You might need to regenerate your lib folder"
|
||||
" if 3rd-party cogs stop working properly.\n"
|
||||
"To regenerate lib folder, load Downloader and use `{prefix}cog reinstallreqs`."
|
||||
"To regenerate lib folder, load Downloader and use `[p]cog reinstallreqs`.",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1202,8 +1193,11 @@ class RedBase(
|
||||
try:
|
||||
await location.send(content, **kwargs)
|
||||
except Exception as _exc:
|
||||
log.exception(
|
||||
f"I could not send an owner notification to ({location.id}){location}"
|
||||
log.error(
|
||||
"I could not send an owner notification to %s (%s)",
|
||||
location,
|
||||
location.id,
|
||||
exc_info=_exc,
|
||||
)
|
||||
|
||||
sends = [wrapped_send(d, content, **kwargs) for d in destinations]
|
||||
|
||||
Reference in New Issue
Block a user