Add clearer error when pages isn't made of embeds nor strings in menu() (#3571)

* Update menus.py

* Update menus.py
This commit is contained in:
jack1142 2020-02-21 04:25:14 +01:00 committed by GitHub
parent 54b712fa71
commit 5ee73cdf63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import asyncio
import contextlib import contextlib
import functools import functools
import warnings import warnings
from typing import Union, Iterable, Optional from typing import Iterable, List, Optional, Union
import discord import discord
from .. import commands from .. import commands
@ -17,7 +17,7 @@ _ReactableEmoji = Union[str, discord.Emoji]
async def menu( async def menu(
ctx: commands.Context, ctx: commands.Context,
pages: list, pages: Union[List[str], List[discord.Embed]],
controls: dict, controls: dict,
message: discord.Message = None, message: discord.Message = None,
page: int = 0, page: int = 0,
@ -57,6 +57,8 @@ async def menu(
RuntimeError RuntimeError
If either of the notes above are violated 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( if not all(isinstance(x, discord.Embed) for x in pages) and not all(
isinstance(x, str) for x in pages isinstance(x, str) for x in pages
): ):