general.py 文件源码

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

项目:Excalibot 作者: endreman0 项目源码 文件源码
def color(self, ctx, *, color : discord.Color):
        """Displays information about a color, by name or hex code."""
        async with ctx.typing(), ctx.bot.http._session.get('http://rgb.to/save/json/color/{:0>6x}'.format(color.value)) as resp:
            color_data = json.loads(await resp.text()) # resp.json() raises an exception because the content type is text/plain
        e = discord.Embed(color=color)
        e.add_field(name='Hex Representation', value=color_data['hex'].upper())
        e.add_field(name='Web-Safe Version', value=color_data['websafe'].upper())
        e.add_field(name='RGB', value='{r}, {g}, {b}'.format(**color_data['rgb']))
        e.add_field(name='HSL', value='{h}deg, {s}%, {l}%'.format(**color_data['hsl']))
        e.add_field(name='HSB', value='{h}deg, {s}%, {b}%'.format(**color_data['hsb']))
        e.add_field(name='CMYK', value='{c}, {m}, {y}, {k}'.format(**color_data['cmyk']))
        await ctx.send(embed=e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号