Make controls in menu() optional (#5678)

* Make `controls` in `menu()` optional

You might wonder, shouldn't we pass `None` to functions from controls?
No, we shouldn't because when `None` is passed, only DEFAULT_CONTROLS
can be used and that means that the length of pages list won't change.

* Update usage in core and core cogs

* Add missing docstrings to `redbot.core.utils.menus` module
This commit is contained in:
Jakub Kuczys
2022-04-16 21:29:12 +02:00
committed by GitHub
parent 955b40ac6d
commit 27bed5010f
15 changed files with 59 additions and 45 deletions

View File

@@ -309,7 +309,7 @@ class CustomCommands(commands.Cog):
if len(msg) > 2000:
msg = f"{msg[:1997]}..."
msglist.append(msg)
await menus.menu(ctx, msglist, menus.DEFAULT_CONTROLS)
await menus.menu(ctx, msglist)
@customcom.command(name="search")
@commands.guild_only()
@@ -572,11 +572,11 @@ class CustomCommands(commands.Cog):
)
embed.set_footer(text=_("Page {num}/{total}").format(num=idx, total=len(pages)))
embed_pages.append(embed)
await menus.menu(ctx, embed_pages, menus.DEFAULT_CONTROLS)
await menus.menu(ctx, embed_pages)
else:
content = "\n".join(map("{0[0]:<12} : {0[1]}".format, results))
pages = list(map(box, pagify(content, page_length=2000, shorten_by=10)))
await menus.menu(ctx, pages, menus.DEFAULT_CONTROLS)
await menus.menu(ctx, pages)
@customcom.command(name="show")
async def cc_show(self, ctx, command_name: str):