[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
This commit is contained in:
Michael H 2019-05-31 15:41:04 -04:00 committed by Kowlin
parent 0e9086ca1f
commit 33b7652b62

View File

@ -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_)