[Utils] Allow menu() to be used DM (#2183)

`ctx.me` handles using `ctx.guild.me` if `ctx.guild is not None`
`ctx.guild.me` directly errors in DMs.
This commit is contained in:
bobloy 2018-10-05 20:02:09 -04:00 committed by Toby Harradine
parent 7b15ad5989
commit fdf3f86ab0

View File

@ -104,7 +104,7 @@ async def next_page(
timeout: float, timeout: float,
emoji: str, emoji: str,
): ):
perms = message.channel.permissions_for(ctx.guild.me) perms = message.channel.permissions_for(ctx.me)
if perms.manage_messages: # Can manage messages, so remove react if perms.manage_messages: # Can manage messages, so remove react
try: try:
await message.remove_reaction(emoji, ctx.author) await message.remove_reaction(emoji, ctx.author)
@ -126,17 +126,17 @@ async def prev_page(
timeout: float, timeout: float,
emoji: str, emoji: str,
): ):
perms = message.channel.permissions_for(ctx.guild.me) perms = message.channel.permissions_for(ctx.me)
if perms.manage_messages: # Can manage messages, so remove react if perms.manage_messages: # Can manage messages, so remove react
try: try:
await message.remove_reaction(emoji, ctx.author) await message.remove_reaction(emoji, ctx.author)
except discord.NotFound: except discord.NotFound:
pass pass
if page == 0: if page == 0:
next_page = len(pages) - 1 # Loop around to the last item page = len(pages) - 1 # Loop around to the last item
else: else:
next_page = page - 1 page = page - 1
return await menu(ctx, pages, controls, message=message, page=next_page, timeout=timeout) return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout)
async def close_menu( async def close_menu(