mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Fix paginator formatting logic
This commit is contained in:
parent
57764330bf
commit
c74e0fc94d
1 changed files with 10 additions and 4 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue