Convert to new Paginator
This commit is contained in:
parent
96ca3208e8
commit
80a6c0c924
@ -193,8 +193,9 @@ 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):
|
||||||
pages = utils.paginate(inspect.getsource(self.bot.get_command(code_name).callback))
|
pag = utils.Paginator()
|
||||||
for page in pages:
|
pag.add(inspect.getsource(self.bot.get_command(code_name).callback))
|
||||||
|
for page in pag.pages():
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
|
|
||||||
@add.command(aliases=['prefix', 'p'])
|
@add.command(aliases=['prefix', 'p'])
|
||||||
|
|||||||
@ -150,10 +150,12 @@ class BotEvents:
|
|||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
|
pag = utils.Paginator()
|
||||||
import traceback
|
import traceback
|
||||||
if ctx.channel.id == 418452585683484680 and type(error) == commands.errors.CommandNotFound:
|
if ctx.channel.id == 418452585683484680 and type(error) == commands.errors.CommandNotFound:
|
||||||
return
|
return
|
||||||
for page in utils.paginate(''.join(traceback.format_exception(type(error), error, error.__traceback__))):
|
pag.add(''.join(traceback.format_exception(type(error), error, error.__traceback__)))
|
||||||
|
for page in pag.pages():
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
|
|
||||||
async def on_guild_join(self, guild):
|
async def on_guild_join(self, guild):
|
||||||
|
|||||||
12
exts/git.py
12
exts/git.py
@ -1,7 +1,7 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import logging
|
import logging
|
||||||
from .imports.utils import paginate, run_command
|
from .imports.utils import Paginator, run_command
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
owner_id = 351794468870946827
|
owner_id = 351794468870946827
|
||||||
@ -29,6 +29,7 @@ class Git:
|
|||||||
@git.command()
|
@git.command()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def pull(self, ctx):
|
async def pull(self, ctx):
|
||||||
|
pag = Paginator(max_line_length=60, max_lines=30, max_chars=1014)
|
||||||
em = discord.Embed(style='rich',
|
em = discord.Embed(style='rich',
|
||||||
title=f'Git Pull',
|
title=f'Git Pull',
|
||||||
color=embed_color)
|
color=embed_color)
|
||||||
@ -40,21 +41,22 @@ class Git:
|
|||||||
' --abbrev-ref HEAD)')), 120) + '\n\n'
|
' --abbrev-ref HEAD)')), 120) + '\n\n'
|
||||||
result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | '
|
result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | '
|
||||||
'sed "s/.*@.*[.].*/ /g"')), 10)
|
'sed "s/.*@.*[.].*/ /g"')), 10)
|
||||||
results = paginate(result, maxlen=1014)
|
pag.add(result)
|
||||||
for page in results[:5]:
|
for page in pag.pages():
|
||||||
em.add_field(name='', value=f'{page}')
|
em.add_field(name='', value=f'{page}')
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@git.command()
|
@git.command()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def status(self, ctx):
|
async def status(self, ctx):
|
||||||
|
pag = Paginator(max_line_length=60, max_lines=30, max_chars=1014)
|
||||||
em = discord.Embed(style='rich',
|
em = discord.Embed(style='rich',
|
||||||
title=f'Git Pull',
|
title=f'Git Pull',
|
||||||
color=embed_color)
|
color=embed_color)
|
||||||
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
|
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
|
||||||
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10)
|
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10)
|
||||||
results = paginate(result, maxlen=1014)
|
pag.add(result)
|
||||||
for page in results[:5]:
|
for page in pag.pages():
|
||||||
em.add_field(name='', value=f'{page}')
|
em.add_field(name='', value=f'{page}')
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
|||||||
17
exts/repl.py
17
exts/repl.py
@ -140,12 +140,11 @@ class Repl:
|
|||||||
fmt = '{}'.format(value)
|
fmt = '{}'.format(value)
|
||||||
try:
|
try:
|
||||||
if fmt is not None:
|
if fmt is not None:
|
||||||
if len(fmt) > 1990:
|
pag = Paginator()
|
||||||
for page in paginate(fmt):
|
pag.add(fmt)
|
||||||
|
for page in pag.pages():
|
||||||
await response.channel.send(page)
|
await response.channel.send(page)
|
||||||
await ctx.send(response.channel)
|
await ctx.send(response.channel)
|
||||||
else:
|
|
||||||
await response.channel.send(f'```py\n{fmt}\n```')
|
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
pass
|
pass
|
||||||
except discord.HTTPException as e:
|
except discord.HTTPException as e:
|
||||||
@ -157,15 +156,13 @@ class Repl:
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
body = self.cleanup_code(body)
|
body = self.cleanup_code(body)
|
||||||
result = await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10)
|
pag = Paginator()
|
||||||
value = result
|
pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10))
|
||||||
for page in paginate(value):
|
for page in pag.pages():
|
||||||
await ctx.send(page)
|
await ctx.send(page)
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
value = f"Command did not complete in the time allowed."
|
await ctx.send(f"Command did not complete in the time allowed.")
|
||||||
for page in paginate(value):
|
|
||||||
await ctx.send(page)
|
|
||||||
await ctx.message.add_reaction('❌')
|
await ctx.message.add_reaction('❌')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user