コード例 #1
0
    async def load_dev(self,
                       ctx: commands.Context,
                       replace_mock: Optional[str] = None):
        """
        Dynamically loads dev cog

        `[replace_mock]` the replacement command name for `[p]mock`
        If nothing is provided this will not replace `[p]mock`.
        """
        dev = Dev()
        # log.debug(dir(dev))
        # return
        if not replace_mock:
            replace_mock = await self.config.replace_mock()
        if replace_mock:
            for command in dev.walk_commands():
                if command.name == "mock":
                    del dev.all_commands[str(command)]
                    command.name = replace_mock
                    dev.all_commands[replace_mock] = command
                    log.debug(command.name)
        self.bot.remove_cog("Dev")
        # remove currently existing dev cog if it's loaded
        self.bot.add_cog(dev)
        await ctx.send(
            _("The following package was loaded: `{pack}`").format(pack="dev"))
コード例 #2
0
 async def initialize(self):
     replace_mock = await self.config.replace_mock()
     if await self.config.auto_load_dev():
         dev = Dev()
         if replace_mock:
             for command in dev.walk_commands():
                 if command.name == "mock":
                     del dev.all_commands[str(command)]
                     command.name = replace_mock
                     dev.all_commands[replace_mock] = command
                     log.debug("Replaced Mock command")
         self.bot.remove_cog("Dev")
         self.bot.add_cog(dev)