1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 22:27:28 +00:00

Fixed MissingArgument

This commit is contained in:
Myned 2017-10-15 13:30:40 -04:00
parent cb5d3549e4
commit bee97afc3e
2 changed files with 13 additions and 5 deletions

View file

@ -66,18 +66,22 @@ class MsG:
# Reverse image searches a linked image using the public iqdb # Reverse image searches a linked image using the public iqdb
@commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL') @commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL')
@checks.del_ctx() @checks.del_ctx()
async def reverse_image_search(self, ctx, url): async def reverse_image_search(self, ctx, url=None):
try: try:
await ctx.trigger_typing() await ctx.trigger_typing()
if url is None and ctx.message.attachments:
url = ctx.message.attachments[0].url
elif url is None:
raise exc.MissingArgument
await ctx.send('✅ **Probable match:**\n{}'.format(await scraper.check_match(url))) await ctx.send('✅ **Probable match:**\n{}'.format(await scraper.check_match(url)))
except exc.MatchError: except exc.MatchError:
await ctx.send('❌ **No probable match.** Make sure the URL directs to an image file.', delete_after=10) await ctx.send('❌ **No probable match.** Make sure the URL directs to an image file.', delete_after=10)
@reverse_image_search.error except exc.MissingArgument:
async def reverse_image_search_error(self, ctx, error): await ctx.send('❌ **Invalid url or file.**', delete_after=10)
if isinstance(error, errext.MissingRequiredArgument):
return await ctx.send('❌ **Invalid url.**', delete_after=10)
async def return_pool(self, *, ctx, booru='e621', query=[]): async def return_pool(self, *, ctx, booru='e621', query=[]):
def on_message(msg): def on_message(msg):

View file

@ -25,6 +25,10 @@ class Exists(Exception):
pass pass
class MissingArgument(Exception):
pass
class PostError(Exception): class PostError(Exception):
pass pass