mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-05 17:02:32 -05:00
[Core] Add Red.wait_until_red_ready() function to wait until post connection startup is done (#3273)
* enhance: add `Red.wait_until_red_ready()` for post connection startup * enhance: fill `bot.owner_id` in our `on_ready` * enhance: log missing destinations in `get_owner_notification_destinations` * chore(changelog): add towncrier entries * chore(changelog): use past form of verb "add"
This commit is contained in:
@@ -48,9 +48,12 @@ def init_events(bot, cli_flags):
|
||||
guilds = len(bot.guilds)
|
||||
users = len(set([m for m in bot.get_all_members()]))
|
||||
|
||||
app_info = await bot.application_info()
|
||||
if bot.owner_id is None:
|
||||
bot.owner_id = app_info.owner.id
|
||||
|
||||
try:
|
||||
data = await bot.application_info()
|
||||
invite_url = discord.utils.oauth_url(data.id)
|
||||
invite_url = discord.utils.oauth_url(app_info.id)
|
||||
except:
|
||||
invite_url = "Could not fetch invite url"
|
||||
|
||||
@@ -75,6 +78,7 @@ def init_events(bot, cli_flags):
|
||||
|
||||
INFO.append("{} cogs with {} commands".format(len(bot.cogs), len(bot.commands)))
|
||||
|
||||
outdated_red_message = ""
|
||||
with contextlib.suppress(aiohttp.ClientError, discord.HTTPException):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get("https://pypi.python.org/pypi/red-discordbot/json") as r:
|
||||
@@ -84,13 +88,10 @@ def init_events(bot, cli_flags):
|
||||
"Outdated version! {} is available "
|
||||
"but you're using {}".format(data["info"]["version"], red_version)
|
||||
)
|
||||
|
||||
await bot.send_to_owners(
|
||||
outdated_red_message = (
|
||||
"Your Red instance is out of date! {} is the current "
|
||||
"version, however you are using {}!".format(
|
||||
data["info"]["version"], red_version
|
||||
)
|
||||
)
|
||||
"version, however you are using {}!"
|
||||
).format(data["info"]["version"], red_version)
|
||||
INFO2 = []
|
||||
|
||||
reqs_installed = {"docs": None, "test": None}
|
||||
@@ -123,6 +124,9 @@ def init_events(bot, cli_flags):
|
||||
print("\nInvite URL: {}\n".format(invite_url))
|
||||
|
||||
bot._color = discord.Colour(await bot._config.color())
|
||||
bot._red_ready.set()
|
||||
if outdated_red_message:
|
||||
await bot.send_to_owners(outdated_red_message)
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx, error, unhandled_by_cog=False):
|
||||
|
||||
Reference in New Issue
Block a user