rng.py 文件源码

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

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def ball(self, ctx, *, question: str):
        """...it's a 8-ball"""
        if not question.endswith('?'):
            return await ctx.send(f"{ctx.author.mention}, that's not a question, I think.")

        colour = discord.Colour(random.randint(0, 0xFFFFFF))

        eight_ball_field_name = '\N{BILLIARDS} 8-ball'
        embed = (discord.Embed(colour=colour)
                 .add_field(name='\N{BLACK QUESTION MARK ORNAMENT} Question', value=question)
                 .add_field(name=eight_ball_field_name, value='\u200b', inline=False)
                 )

        msg = await ctx.send(content=ctx.author.mention, embed=embed)

        new_colour = discord.Colour.from_rgb(*(round(c * 0.7) for c in colour.to_rgb()))
        default = _8default._replace(colour=new_colour)

        async with ctx.typing():
            for answer in (default, random.choice(BALL_ANSWERS)):
                await asyncio.sleep(random.uniform(0.75, 1.25) * 2)
                embed.colour = answer.colour
                embed.set_field_at(-1, name=eight_ball_field_name, value=answer.answer, inline=False)
                await msg.edit(embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号