1
0
Fork 0
mirror of synced 2024-04-29 18:22:36 +12:00

Paginate through all results instead of only showing 10

This commit is contained in:
Dan Hess 2021-03-31 23:48:45 -08:00
parent 032282e132
commit 968713dd18

View file

@ -1,6 +1,6 @@
import json import json
from discord.ext import commands from discord.ext import commands
from utils import conjugator, checks, request from utils import conjugator, checks, request, Pages, CannotPaginate
class Japanese(commands.Cog): class Japanese(commands.Cog):
@ -98,11 +98,15 @@ query ($name: String) {
reverse=True, reverse=True,
) )
# And convert to a string # And convert to a string
data = "\n".join( output = "\n".join(
f"**Score**: {x['score']} | **Title**: {x['title']}" for x in data[:10] f"**Score**: {x['score']} | **Title**: {x['title']}" for x in data
) )
await ctx.send(data) try:
pages = Pages(ctx, entries=output, per_page=7)
await pages.paginate()
except CannotPaginate as e:
await ctx.send(str(e))
def setup(bot): def setup(bot):