ram.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:kitsuchan-2 作者: n303p4 项目源码 文件源码
def _build_commands(self):
        for key in self.owoe.types:

            # Avoid duplicate commands by removing them.
            if key in self.bot.all_commands.keys():
                self.bot.remove_command(key)

            helptext = f"{key.capitalize()}!"

            async def callback(self, ctx, *tags):
                tags = list(tags)
                for tag in tags:
                    if tag not in self.owoe.tags:
                        tags.remove(tag)
                url_image = await self.owoe.random_image(type_=ctx.command.name, tags=tags)
                if isinstance(url_image, str):
                    embed = discord.Embed()
                    embed.set_image(url=url_image)
                    embed.set_footer(text="Powered by weeb.sh")
                    await ctx.send(embed=embed)
                    return
                await ctx.send("No image matching your criteria was found.")

            # Ew, gross.
            command = commands.command(name=key, help=helptext)(callback)
            command = commands.cooldown(6, 12, commands.BucketType.channel)(command)
            command.instance = self
            setattr(self, key, command)
            self.bot.add_command(command)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号