mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
suppress ValueError > isdigit(), reaction order logic
This commit is contained in:
parent
d86c695ee4
commit
8e0d8259fb
1 changed files with 1143 additions and 1143 deletions
|
@ -472,7 +472,7 @@ class MsG:
|
|||
def on_message(msg):
|
||||
if msg.content.lower() == 'cancel' and msg.author is ctx.author and msg.channel is ctx.channel:
|
||||
raise exc.Abort
|
||||
with suppress(ValueError):
|
||||
elif msg.content.isdigit():
|
||||
if int(msg.content) <= len(pools) and int(msg.content) > 0 and msg.author is ctx.author and msg.channel is ctx.channel:
|
||||
return True
|
||||
return False
|
||||
|
@ -529,7 +529,7 @@ class MsG:
|
|||
return False
|
||||
|
||||
def on_message(msg):
|
||||
with suppress(ValueError):
|
||||
if msg.content.isdigit():
|
||||
if int(msg.content) <= len(posts) and msg.author is ctx.author and msg.channel is ctx.channel:
|
||||
return True
|
||||
return False
|
||||
|
@ -547,7 +547,8 @@ class MsG:
|
|||
values = list(posts.values())
|
||||
|
||||
embed = d.Embed(
|
||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=dest.me.color if isinstance(dest.channel, d.TextChannel) else self.color).set_image(url=values[c - 1]['url'])
|
||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=dest.me.color if isinstance(dest.channel, d.TextChannel) else self.color)
|
||||
embed.set_image(url=values[c - 1]['url'])
|
||||
embed.set_author(name=pool['name'],
|
||||
url='https://e621.net/pool/show?id={}'.format(pool['id']), icon_url=ctx.author.avatar_url)
|
||||
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
||||
|
@ -621,18 +622,12 @@ class MsG:
|
|||
|
||||
except UnboundLocalError:
|
||||
await dest.send('**Exited paginator.**')
|
||||
|
||||
finally:
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
except asyncio.TimeoutError:
|
||||
try:
|
||||
await paginator.edit(content='**Paginator timed out.**')
|
||||
|
||||
except UnboundLocalError:
|
||||
await dest.send('**Paginator timed out.**')
|
||||
|
||||
finally:
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
except exc.NotFound:
|
||||
await ctx.send('**Pool not found.**', delete_after=10)
|
||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||
|
@ -641,11 +636,16 @@ class MsG:
|
|||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||
|
||||
finally:
|
||||
if starred:
|
||||
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
||||
|
||||
for url in starred:
|
||||
await ctx.author.send('`{} / {}`\n{}'.format(starred.index(url) + 1, len(starred), url))
|
||||
if len(starred) > 5:
|
||||
await asyncio.sleep(self.RATE_LIMIT)
|
||||
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
|
||||
# Messy code that checks image limit and tags in blacklists
|
||||
async def check_return_posts(self, ctx, *, booru='e621', tags=[], limit=1, previous={}):
|
||||
guild = ctx.guild if isinstance(
|
||||
|
@ -714,7 +714,7 @@ class MsG:
|
|||
return False
|
||||
|
||||
def on_message(msg):
|
||||
with suppress(ValueError):
|
||||
if msg.content.isdigit():
|
||||
if int(msg.content) <= len(posts) and msg.author is ctx.author and msg.channel is ctx.channel:
|
||||
return True
|
||||
return False
|
||||
|
@ -735,7 +735,8 @@ class MsG:
|
|||
values = list(posts.values())
|
||||
|
||||
embed = d.Embed(
|
||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color).set_image(url=values[c - 1]['url'])
|
||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color)
|
||||
embed.set_image(url=values[c - 1]['url'])
|
||||
embed.set_author(name=formatter.tostring(tags, random=True),
|
||||
url='https://e621.net/post?tags={}'.format(','.join(tags)), icon_url=ctx.author.avatar_url)
|
||||
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
||||
|
@ -817,18 +818,12 @@ class MsG:
|
|||
|
||||
except UnboundLocalError:
|
||||
await dest.send('**Exited paginator.**')
|
||||
|
||||
finally:
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
except asyncio.TimeoutError:
|
||||
try:
|
||||
await paginator.edit(content='**Paginator timed out.**')
|
||||
|
||||
except UnboundLocalError:
|
||||
await dest.send('**Paginator timed out.**')
|
||||
|
||||
finally:
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
except exc.NotFound as e:
|
||||
await ctx.send('`{}` **not found.**'.format(e), delete_after=10)
|
||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||
|
@ -846,11 +841,16 @@ class MsG:
|
|||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||
|
||||
finally:
|
||||
if starred:
|
||||
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
||||
|
||||
for url in starred:
|
||||
await ctx.author.send('`{} / {}`\n{}'.format(starred.index(url) + 1, len(starred), url))
|
||||
if len(starred) > 5:
|
||||
await asyncio.sleep(self.RATE_LIMIT)
|
||||
|
||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
|
||||
@e621_paginator.error
|
||||
async def e621_paginator_error(self, ctx, error):
|
||||
if isinstance(error, errext.CheckFailure):
|
||||
|
|
Loading…
Reference in a new issue