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)
评论列表
文章目录