@@ -0,0 +1,2491 @@
+%22%22%22%0ACore commands.%0A%22%22%22%0Aimport inspect%0A%0Afrom discord.ext import commands%0Afrom discord.ext.commands import Command, CheckFailure%0A%0Afrom joku.bot import Jokusoramame%0A%0A%0Aclass Core(object):%0A    %22%22%22%0A    Core command class.%0A    %22%22%22%0A%0A    def __init__(self, bot: Jokusoramame):%0A        self.bot = bot%0A%0A    def can_run_recursive(self, ctx, command: Command):%0A        # Check if the command has a parent.%0A        if command.parent is not None:%0A            rec = self.can_run_recursive(ctx, command.parent)%0A            if not rec:%0A                return False%0A%0A        try:%0A            can_run = command.can_run(ctx)%0A        except CheckFailure:%0A            return False%0A        else:%0A            return can_run%0A%0A    @commands.command(pass_context=True)%0A    async def help(self, ctx, command: str = None):%0A        %22%22%22%0A        Help command.%0A        %22%22%22%0A        prefix = ctx.prefix%0A%0A        if command is None:%0A            # List the commands.%0A            base = %22**Commands:**%5CnUse %60%7B%7Dhelp %3Ccommand%3E%60 for more information about each command.%5Cn%5Cn%22.format(prefix)%0A            for n, (name, cls) in enumerate(self.bot.cogs.items()):%0A                # Increment N, so we start at 1 index instead of 0.%0A                n += 1%0A%0A                cmds = %5B%5D%0A%0A                # Get a list of commands on the cog.%0A                members = inspect.getmembers(cls)%0A                for cname, m in members:%0A                    if isinstance(m, Command):%0A                        # Check if the author can run the command.%0A                        try:%0A                            if self.can_run_recursive(ctx, m):%0A                                cmds.append(%22%60%22 + m.name + %22%60%22)%0A                        except CheckFailure:%0A                            pass%0A%0A                base += %22**%7B%7D. %7B%7D: ** %7B%7D%5Cn%22.format(n, name, ' '.join(cmds) if cmds else %22%60No commands available to %22%0A                                                                                        %22you.%60%22)%0A%0A            await self.bot.say(base)%0A        else:%0A            # Check if the command is in the commands dict.%0A            if command not in self.bot.commands:%0A                await self.bot.say(%22:x: This command does not exist.%22)%0A                return%0A            # Use the default HelpFormatter to construct a nice message.%0A            fmtted = self.bot.formatter.format_help_for(ctx, self.bot.commands%5Bcommand%5D)%0A            for page in fmtted:%0A                await self.bot.say(page)%0A%0A%0Adef setup(bot: Jokusoramame):%0A    bot.add_cog(Core(bot))%0A

Add core cog.