From 33b7652b6232fc77381b8cc25115c502eff1e51a Mon Sep 17 00:00:00 2001 From: Michael H Date: Fri, 31 May 2019 15:41:04 -0400 Subject: [PATCH] [Help] Detatch menu usage into a task (#2725) * [Help] Detatch menu usage into a task - This resolves #2712 - This is a minor API change. Conceptually, the difference is minor in nature `bot.send_help_for` returns when help has been sent, however this can now be prior to when the help menu (if one is in use) is closed. - This should not be considered breaking as there is and has been a a warning about this file's APIs being still up for unannounced modifications No developers should be currently relying on this behavior. * operator precendence --- redbot/core/commands/help.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index eb6fbf49e..bff76c292 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -26,6 +26,7 @@ # Additionally, this gives our users a bit more customization options including by # 3rd party cogs down the road. +import asyncio from collections import namedtuple from typing import Union, List, AsyncIterator, Iterable, cast @@ -555,10 +556,13 @@ class RedHelpFormatter: ) ) else: - if len(pages) > 1: - await menus.menu(ctx, pages, menus.DEFAULT_CONTROLS) - else: - await menus.menu(ctx, pages, {"\N{CROSS MARK}": menus.close_menu}) + # Specifically ensuring the menu's message is sent prior to returning + m = await (ctx.send(embed=pages[0]) if embed else ctx.send(pages[0])) + c = menus.DEFAULT_CONTROLS if len(pages) > 1 else {"\N{CROSS MARK}": menus.close_menu} + # Allow other things to happen during menu timeout/interaction. + asyncio.create_task(menus.menu(ctx, pages, c, message=m)) + # menu needs reactions added manually since we fed it a messsage + menus.start_adding_reactions(m, c.keys()) @commands.command(name="help", hidden=True, i18n=T_)