Added required argument to Paginator instances
This commit is contained in:
parent
cb7290be00
commit
222159f059
@ -193,7 +193,7 @@ class Admin:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def view_code(self, ctx, code_name):
|
async def view_code(self, ctx, code_name):
|
||||||
pag = utils.Paginator(prefix='```py', suffix='```')
|
pag = utils.Paginator(self.bot, prefix='```py', suffix='```')
|
||||||
pag.add(inspect.getsource(self.bot.get_command(code_name).callback))
|
pag.add(inspect.getsource(self.bot.get_command(code_name).callback))
|
||||||
for page in pag.pages():
|
for page in pag.pages():
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
|
|||||||
@ -141,7 +141,7 @@ class Repl:
|
|||||||
fmt = '{}'.format(value)
|
fmt = '{}'.format(value)
|
||||||
try:
|
try:
|
||||||
if fmt is not None:
|
if fmt is not None:
|
||||||
pag = Paginator()
|
pag = Paginator(self.bot)
|
||||||
pag.add(fmt)
|
pag.add(fmt)
|
||||||
for page in pag.pages():
|
for page in pag.pages():
|
||||||
await response.channel.send(page)
|
await response.channel.send(page)
|
||||||
@ -157,7 +157,7 @@ class Repl:
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
body = self.cleanup_code(body)
|
body = self.cleanup_code(body)
|
||||||
pag = Paginator()
|
pag = Paginator(self.bot)
|
||||||
pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10))
|
pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10))
|
||||||
for page in pag.pages():
|
for page in pag.pages():
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
|
|||||||
@ -128,9 +128,16 @@ class Paginator:
|
|||||||
self._inline_char = inline_char
|
self._inline_char = inline_char
|
||||||
self._embed_title = ''
|
self._embed_title = ''
|
||||||
self._embed_description = ''
|
self._embed_description = ''
|
||||||
|
self._embed_color = None
|
||||||
|
self._embed_thumbnail = None
|
||||||
|
self._embed_url = None
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
|
|
||||||
def set_embed_meta(self, title: str='\uFFF0', description: str='\uFFF0'):
|
def set_embed_meta(self, title: str='\uFFF0',
|
||||||
|
description: str='\uFFF0',
|
||||||
|
color: discord.Colour=None,
|
||||||
|
thumbnail: str=None,
|
||||||
|
url: str=None):
|
||||||
if len(title) <= self._max_field_name:
|
if len(title) <= self._max_field_name:
|
||||||
self._embed_title = title
|
self._embed_title = title
|
||||||
else:
|
else:
|
||||||
@ -139,6 +146,9 @@ class Paginator:
|
|||||||
self._embed_description = description
|
self._embed_description = description
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Provided Description is too long')
|
raise RuntimeError('Provided Description is too long')
|
||||||
|
self._embed_color = color
|
||||||
|
self._embed_thumbnail = thumbnail
|
||||||
|
self._embed_url = url
|
||||||
|
|
||||||
def pages(self) -> typing.List[str]:
|
def pages(self) -> typing.List[str]:
|
||||||
_pages = list()
|
_pages = list()
|
||||||
@ -244,6 +254,12 @@ class Paginator:
|
|||||||
description=self._embed_description,
|
description=self._embed_description,
|
||||||
color=self._bot.embed_color,
|
color=self._bot.embed_color,
|
||||||
)
|
)
|
||||||
|
if self._embed_thumbnail:
|
||||||
|
em.set_thumbnail(url=self._embed_thumbnail)
|
||||||
|
if self._embed_url:
|
||||||
|
em.url = self._embed_url
|
||||||
|
if self._embed_color:
|
||||||
|
em.color = self._embed_color
|
||||||
em.set_footer(text=f'{i + 1}/{_len_pages}')
|
em.set_footer(text=f'{i + 1}/{_len_pages}')
|
||||||
for field in page:
|
for field in page:
|
||||||
em.add_field(name=field['name'], value=field['value'], inline=field['inline'])
|
em.add_field(name=field['name'], value=field['value'], inline=field['inline'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user