Example #1
0
 async def sell_error(self, ctx, error: Exception):
     if isinstance(error, commands.BadArgument):
         msg = "Bad argument;\n`!sell [ticker (KBO)] [amount (13)] [price (12.50)]`"
     elif isinstance(error, commands.MissingRequiredArgument):
         msg = "Missing arguments;\n`!sell [ticker (KBO)] [amount (13)] [price (12.50)(optional)]`"
     elif isinstance(error, commands.CommandInvokeError):
         if isinstance(error.original, NotEnoughPositionsToSell):
             msg = "You don't have enough positions to sell!"
         else:
             msg = uncaught(error.original)
     else:
         msg = uncaught(error)
     await ctx.send(embed=Embedder.error(msg))
Example #2
0
 async def portfolio_error(self, ctx, error: Exception):
     if isinstance(error, commands.BadArgument):
         msg = "Bad argument;\n`!portfolio [m or mobile (for mobile view)]`"
     elif isinstance(error, NoPositionsException):
         msg = "No position was found with the user!\nTry `!buy` command first to add positions."
     else:
         msg = uncaught(error)
     await ctx.send(embed=Embedder.error(msg))
Example #3
0
 async def buy_error(self, ctx, error: Exception):
     if isinstance(error, commands.BadArgument):
         msg = "Bad argument;\n`!buy [ticker (KBO)] [amount (13)] [price (12.50)(optional)]`"
     elif isinstance(error, commands.MissingRequiredArgument):
         msg = "Missing arguments;\n`!buy [ticker (KBO)] [amount (13)] [price (12.50)(optional)]`"
     else:
         msg = uncaught(error)
     await ctx.send(embed=Embedder.error(msg))
Example #4
0
async def sell_error(ctx, error):
    if isinstance(error, commands.BadArgument):
        msg = "Bad argument;\n`!sell [ticker (KBO)] [amount (13)] [price (12.50)]`"
    elif isinstance(error, commands.CommandInvokeError):
        msg = "Invalid ticker."
    else:
        msg = uncaught(error)
    await ctx.send(embed=Embedder.error(msg))
Example #5
0
async def on_command_error(ctx, error: Exception):
    if isinstance(error, commands.CommandNotFound):
        return await ctx.send(embed=Embedder.error("Command does not exist."))
    elif hasattr(ctx.command, "on_error"):
        return
    else:
        msg = uncaught(error)
    return await ctx.send(embed=Embedder.error(msg))
Example #6
0
 async def graph_error(self, ctx, error: Exception):
     if isinstance(error, commands.MissingRequiredArgument):
         return await ctx.send(
             embed=Embedder.error(
                 "`!graph ticker data_range`\n"
                 "Data ranges: [1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, ytd, max]"
             )
         )
     await ctx.send(embed=Embedder.error(uncaught(error)))
Example #7
0
async def live_error(ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        msg = """
        Came across an error while processing your request.
        Check if your region corresponds to the proper exchange,
        or re-check the ticker you used.
        """
    else:
        msg = uncaught(error)
    await ctx.send(embed=Embedder.error(msg))
Example #8
0
 async def hist_error(self, ctx, error: Exception):
     if isinstance(error, commands.MissingRequiredArgument):
         return await ctx.send(
             embed=Embedder.error(
                 "`!hist ticker data_range`\n"
                 "Data ranges:\n"
                 "13d = 13 **trading** days\n"
                 "2wk = 2 **calendar** weeks\n"
                 "5mo = 5 **calendar** months\n"
                 "3y = 3 **calendar** years"
             )
         )
     await ctx.send(embed=Embedder.error(uncaught(error)))
Example #9
0
async def alert_error(ctx, error):
    if isinstance(error, commands.CommandError):
        msg = 'Came across an error while processing your request. Please check your ticker again.'
    else:
        msg = uncaught(error)
    await ctx.send(embed=Embedder.error(msg))
Example #10
0
async def news_error(ctx, error):
    if isinstance(error, commands.CommandError):
        msg = 'Came across an error while processing your request.'
    else:
        msg = uncaught(error)
    await ctx.send(embed=Embedder.error(msg))