[Core] Added co-owners to outdated message warnings (#2664)

* Added co-owners to potentially DMd users

* Fetch the cached of every guild, see comments of #2664

* Ensure owners can be DM'd.

* Refactoring try block.
This commit is contained in:
Kowlin 2019-05-14 06:33:05 +02:00 committed by Michael H
parent 3b6d4d9df6
commit 3de1a265ea
2 changed files with 22 additions and 8 deletions

View File

@ -104,7 +104,9 @@ def main():
log.debug("Data Path: %s", data_manager._base_data_path()) log.debug("Data Path: %s", data_manager._base_data_path())
log.debug("Storage Type: %s", data_manager.storage_type()) log.debug("Storage Type: %s", data_manager.storage_type())
red = Red(cli_flags=cli_flags, description=description, dm_help=None) red = Red(
cli_flags=cli_flags, description=description, dm_help=None, fetch_offline_members=True
)
init_global_checks(red) init_global_checks(red)
init_events(red, cli_flags) init_events(red, cli_flags)
red.add_cog(Core(red)) red.add_cog(Core(red))

View File

@ -119,13 +119,25 @@ def init_events(bot, cli_flags):
"Outdated version! {} is available " "Outdated version! {} is available "
"but you're using {}".format(data["info"]["version"], red_version) "but you're using {}".format(data["info"]["version"], red_version)
) )
owner = await bot.fetch_user(bot.owner_id)
await owner.send( owners = []
"Your Red instance is out of date! {} is the current " owner = bot.get_user(bot.owner_id)
"version, however you are using {}!".format( if owner is not None:
data["info"]["version"], red_version owners.append(owner)
)
) for co_owner in bot._co_owners:
co_owner = await bot.get_user(co_owner)
if co_owner is not None:
owners.append(co_owner)
for owner in owners:
with contextlib.suppress(discord.HTTPException):
await owner.send(
"Your Red instance is out of date! {} is the current "
"version, however you are using {}!".format(
data["info"]["version"], red_version
)
)
INFO2 = [] INFO2 = []
mongo_enabled = storage_type() != "JSON" mongo_enabled = storage_type() != "JSON"