1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-25 06:37:29 +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 from discord.ext.commands import Paginator
@ -28,8 +30,8 @@ async def paginate(
i, i,
start='', start='',
prefix='', prefix='',
kprefix='', kprefix='`',
ksuffix='\n', ksuffix='`\n',
eprefix='```\n', eprefix='```\n',
ejoin=' ', ejoin=' ',
esuffix='\n```', esuffix='\n```',
@ -37,17 +39,21 @@ async def paginate(
end=''): end=''):
paginator = Paginator(prefix=prefix, suffix=suffix) paginator = Paginator(prefix=prefix, suffix=suffix)
messages = [] messages = []
i = copy.deepcopy(i)
if start: if start:
paginator.add_line(start) paginator.add_line(start)
if type(i) in (tuple, list, set): if type(i) in (tuple, list, set):
if not i:
i = (' ')
paginator.add_line(eprefix + f'{ejoin}'.join(i) + esuffix) paginator.add_line(eprefix + f'{ejoin}'.join(i) + esuffix)
elif type(i) is dict: elif type(i) is dict:
if not i:
i = {'': ' '}
for k, e in sorted(i.items()): for k, e in sorted(i.items()):
if e and (k not in e) and (len(e) >= 1): paginator.add_line(kprefix if k else '' + k + ksuffix if k else '' + eprefix + f'{ejoin}'.join(e) + esuffix)
paginator.add_line(kprefix + k + ksuffix + eprefix + f'{ejoin}'.join(e) + esuffix)
if end: if end:
paginator.add_line(end) paginator.add_line(end)