1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-23 22:27:27 +00:00

Fix paginator formatting logic

This commit is contained in:
Dylan Dizon 2018-11-15 18:58:21 -05:00
parent 57764330bf
commit c74e0fc94d

View file

@ -1,3 +1,5 @@
import copy
from discord.ext.commands import Paginator
@ -28,8 +30,8 @@ async def paginate(
i,
start='',
prefix='',
kprefix='',
ksuffix='\n',
kprefix='`',
ksuffix='`\n',
eprefix='```\n',
ejoin=' ',
esuffix='\n```',
@ -37,17 +39,21 @@ async def paginate(
end=''):
paginator = Paginator(prefix=prefix, suffix=suffix)
messages = []
i = copy.deepcopy(i)
if start:
paginator.add_line(start)
if type(i) in (tuple, list, set):
if not i:
i = (' ')
paginator.add_line(eprefix + f'{ejoin}'.join(i) + esuffix)
elif type(i) is dict:
if not i:
i = {'': ' '}
for k, e in sorted(i.items()):
if e and (k not in e) and (len(e) >= 1):
paginator.add_line(kprefix + k + ksuffix + eprefix + f'{ejoin}'.join(e) + esuffix)
paginator.add_line(kprefix if k else '' + k + ksuffix if k else '' + eprefix + f'{ejoin}'.join(e) + esuffix)
if end:
paginator.add_line(end)