[Help] Send menus to dm if maxpages is 0 (#5375)

Co-authored-by: Dav <dav@mail.stopdavabuse.de>
Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
Dav 2024-01-19 21:06:14 +01:00 committed by GitHub
parent 409ece427f
commit dbd71db6a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 10 deletions

View File

@ -1475,9 +1475,6 @@ helpset maxpages
Set the maximum number of help pages sent in a server channel.
.. Note:: This setting does not apply to menu help.
If a help message contains more pages than this value, the help message will
be sent to the command author via DM. This is to help reduce spam in server
text channels.
@ -4378,4 +4375,4 @@ uptime
**Description**
Shows Red's uptime.
Shows Red's uptime.

View File

@ -856,23 +856,36 @@ class RedHelpFormatter(HelpFormatterABC):
if help_settings.use_menus.value >= HelpMenuSetting.buttons.value:
use_select = help_settings.use_menus.value == 3
select_only = help_settings.use_menus.value == 4
await SimpleMenu(
menu = SimpleMenu(
pages,
timeout=help_settings.react_timeout,
use_select_menu=use_select,
use_select_only=select_only,
).start(ctx)
)
# Send menu to DMs if max pages is 0
if help_settings.max_pages_in_guild == 0:
await menu.start_dm(ctx.author)
else:
await menu.start(ctx)
elif (
can_user_react_in(ctx.me, ctx.channel)
and help_settings.use_menus is HelpMenuSetting.reactions
):
use_DMs = help_settings.max_pages_in_guild == 0
destination = ctx.author if use_DMs else ctx.channel
# 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]))
m = await (destination.send(embed=pages[0]) if embed else destination.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.
if use_DMs:
menu_ctx = await ctx.bot.get_context(m)
# Monkeypatch so help listens for reactions from the original author, not the bot
menu_ctx.author = ctx.author
else:
menu_ctx = ctx
asyncio.create_task(
menus.menu(ctx, pages, c, message=m, timeout=help_settings.react_timeout)
menus.menu(menu_ctx, pages, c, message=m, timeout=help_settings.react_timeout)
)
# menu needs reactions added manually since we fed it a message
menus.start_adding_reactions(m, c.keys())

View File

@ -4446,8 +4446,6 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
async def helpset_maxpages(self, ctx: commands.Context, pages: int):
"""Set the maximum number of help pages sent in a server channel.
Note: This setting does not apply to menu help.
If a help message contains more pages than this value, the help message will
be sent to the command author via DM. This is to help reduce spam in server
text channels.