Esempio n. 1
0
 async def unload(self, ctx, *, module: str):
     """Unloads a module."""
     try:
         self.bot.unload_extension(module)
     except Exception as e:
         await ctx.send(codeblocks.error_to_codeblock(e))
     else:
         await ctx.send(f':gear: Unloaded {module}')
Esempio n. 2
0
 async def unload(self, ctx, *, module: str):
     """Unloads a module."""
     try:
         self.bot.unload_extension(module)
     except Exception as e:
         await ctx.reply(codeblocks.error_to_codeblock(e),
                         mention_author=True)
     else:
         await ctx.reply(f':gear: Unloaded {module}', mention_author=False)
Esempio n. 3
0
    async def debug(self, ctx, *, code: str):
        """Evaluates code."""
        code = code.strip('` ')

        env = {
            'bot': self.bot,
            'ctx': ctx,
        }
        env.update(globals())
        try:
            result = eval(code, env)
            if inspect.isawaitable(result):
                result = await result
        except Exception as e:
            etc = codeblocks.error_to_codeblock(e)
            if len(etc) > 2000:
                await ctx.send('Too long for discord, output sent to console.')
            else:
                return await ctx.send(etc)
        else:
            await ctx.send(f"```py\n{result}```")