Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Jan 19, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions redbot/core/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,14 +806,14 @@ async def send_pages(

# save on config calls
channel_permissions = ctx.channel.permissions_for(ctx.me)
max_pages_in_guild = help_settings.max_pages_in_guild

if not (
channel_permissions.add_reactions
and channel_permissions.read_message_history
and help_settings.use_menus
):

max_pages_in_guild = help_settings.max_pages_in_guild
use_DMs = len(pages) > max_pages_in_guild
destination = ctx.author if use_DMs else ctx.channel
delete_delay = help_settings.delete_delay
Expand Down Expand Up @@ -855,12 +855,19 @@ async def _delete_delay_help(

asyncio.create_task(_delete_delay_help(destination, messages, delete_delay))
else:
use_DMs = 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)
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())
Expand Down