async def color(self, ctx, *, color: discord.Color): '''Display info on a color.\n **Example:```yml\n♤color #8bb3f8```** ''' buffer = utils.display_color(color) r, g, b = color.to_rgb() c, m, y, k = utils.rgb_to_cmyk(*color.to_rgb()) h, s, l = utils.rgb_to_hsl(*color.to_rgb()) h, s_, v = utils.rgb_to_hsv(*color.to_rgb()) file = File(buffer, 'unknown.png') embed = Embed( description= '**[Color picker](https://www.google.com/search?q=color+picker)**', color=color) embed.set_author(name=color) embed.add_field(name='RGB', value=f'{r}, {g}, {b}') embed.add_field(name='CMYK', value=f'{c:.0%}, {m:.0%}, {y:.0%}, {k:.0%}') embed.add_field(name='HSL', value=f'{round(h)}°, {s:.0%}, {l:.0%}') embed.add_field(name='HSV', value=f'{round(h)}°, {s_:.0%}, {v:.0%}') embed.set_image(url='attachment://unknown.png') await ctx.send(file=file, embed=embed, reference=ctx.message.to_reference(), mention_author=False)
async def role(self, ctx, *, role: discord.Role): '''Display info on a role.\n **Example:```yml\n♤role Tau\n♤role 657766595321528349```** ''' buffer = utils.display_color(role.color) perms = sorted((perm, value) for perm, value in iter(role.permissions)) plen = len(max(perms, key=lambda p: len(p[0]))[0]) half = len(perms) // 2 fields = [''] * 2 for i, tup in enumerate(perms): perm, value = tup tog = utils.Emoji.on if value else utils.Emoji.off align = ' ' * (plen - len(perm)) fields[i > half] += f'**`{perm}{align}`** {tog}\n' plural = 's' if len(role.members) != 1 else '' mention = role.mention if not role.is_default() else '@everyone' embed = Embed( description=f'**{mention}\n`{len(role.members)} member{plural}`**', color=role.color) embed.add_field(name='Permissions', value=fields[0]) embed.add_field(name='\u200b', value=fields[1]) embed.set_image(url='attachment://unknown.png') embed.set_footer(text=f'ID: {role.id}') await ctx.reply(file=File(buffer, 'unknown.png'), embed=embed, mention_author=False)
def ai_turn(bot, game): player = game.current_player while player.ai: reply = '' from ISMCTS import UNOState, ISMCTS from utils import display_color, display_name chat_id = game.chat.id state = UNOState(game) move = ISMCTS(state, itermax=ai_iterations, verbose=False) if move == 'draw': reply += 'Drawing\n' else: sticker_async(bot, chat_id, sticker=c.STICKERS[str(move)]) if move.special: reply += "Choosing color: %s\n" % display_color(move.color) state.DoMove(move) if len(player.cards) == 1: reply += "UNO!\n" if len(player.cards) == 0: reply += "%s won!\n" % player.user.first_name if len(game.players) < 3: reply += "Game ended!" gm.end_game(chat_id, player.next.user) else: player.leave() player = game.current_player if game in gm.chatid_games.get(chat_id, list()): reply += "Next player: " + display_name(player.user) send_async(bot, chat_id, text=reply)
def add_choose_color(results, game): """Add choose color options""" for color in c.COLORS: results.append( InlineQueryResultArticle( id=color, title=_("Choose Color"), description=display_color(color), input_message_content=InputTextMessageContent( display_color_group(color, game))))
def add_choose_color(results, game): """Add choose color options""" for color in c.COLORS: results.append( InlineQueryResultArticle( id=color, title=_("Choose Color"), description=display_color(color), input_message_content= InputTextMessageContent(display_color_group(color, game)) ) )