From 5ee73cdf63da0632e6953a50bdeda238bca018e3 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 21 Feb 2020 04:25:14 +0100 Subject: [PATCH] Add clearer error when `pages` isn't made of embeds nor strings in menu() (#3571) * Update menus.py * Update menus.py --- redbot/core/utils/menus.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/redbot/core/utils/menus.py b/redbot/core/utils/menus.py index f4e9cf364..6285c0e70 100644 --- a/redbot/core/utils/menus.py +++ b/redbot/core/utils/menus.py @@ -6,7 +6,7 @@ import asyncio import contextlib import functools import warnings -from typing import Union, Iterable, Optional +from typing import Iterable, List, Optional, Union import discord from .. import commands @@ -17,7 +17,7 @@ _ReactableEmoji = Union[str, discord.Emoji] async def menu( ctx: commands.Context, - pages: list, + pages: Union[List[str], List[discord.Embed]], controls: dict, message: discord.Message = None, page: int = 0, @@ -57,6 +57,8 @@ async def menu( RuntimeError If either of the notes above are violated """ + if not isinstance(pages[0], (discord.Embed, str)): + raise RuntimeError("Pages must be of type discord.Embed or str") if not all(isinstance(x, discord.Embed) for x in pages) and not all( isinstance(x, str) for x in pages ):