mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[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:
parent
409ece427f
commit
dbd71db6a8
@ -1475,9 +1475,6 @@ helpset maxpages
|
|||||||
|
|
||||||
Set the maximum number of help pages sent in a server channel.
|
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
|
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
|
be sent to the command author via DM. This is to help reduce spam in server
|
||||||
text channels.
|
text channels.
|
||||||
|
|||||||
@ -856,23 +856,36 @@ class RedHelpFormatter(HelpFormatterABC):
|
|||||||
if help_settings.use_menus.value >= HelpMenuSetting.buttons.value:
|
if help_settings.use_menus.value >= HelpMenuSetting.buttons.value:
|
||||||
use_select = help_settings.use_menus.value == 3
|
use_select = help_settings.use_menus.value == 3
|
||||||
select_only = help_settings.use_menus.value == 4
|
select_only = help_settings.use_menus.value == 4
|
||||||
await SimpleMenu(
|
menu = SimpleMenu(
|
||||||
pages,
|
pages,
|
||||||
timeout=help_settings.react_timeout,
|
timeout=help_settings.react_timeout,
|
||||||
use_select_menu=use_select,
|
use_select_menu=use_select,
|
||||||
use_select_only=select_only,
|
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 (
|
elif (
|
||||||
can_user_react_in(ctx.me, ctx.channel)
|
can_user_react_in(ctx.me, ctx.channel)
|
||||||
and help_settings.use_menus is HelpMenuSetting.reactions
|
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
|
# 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}
|
c = menus.DEFAULT_CONTROLS if len(pages) > 1 else {"\N{CROSS MARK}": menus.close_menu}
|
||||||
# Allow other things to happen during menu timeout/interaction.
|
# 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(
|
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
|
# menu needs reactions added manually since we fed it a message
|
||||||
menus.start_adding_reactions(m, c.keys())
|
menus.start_adding_reactions(m, c.keys())
|
||||||
|
|||||||
@ -4446,8 +4446,6 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
async def helpset_maxpages(self, ctx: commands.Context, pages: int):
|
async def helpset_maxpages(self, ctx: commands.Context, pages: int):
|
||||||
"""Set the maximum number of help pages sent in a server channel.
|
"""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
|
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
|
be sent to the command author via DM. This is to help reduce spam in server
|
||||||
text channels.
|
text channels.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user