async def embd(ctx, *args): colors = { "red": Color.red(), "green": Color.green(), "gold": Color.gold(), "orange": Color.orange(), "blue": Color.blue(), "purple": Color.purple(), "teal": Color.teal(), "magenta": Color.magenta(), "grey": Color.lighter_grey() } if args: argstr = " ".join(args) if "-c " in argstr: text = argstr.split("-c ")[0] color_str = argstr.split("-c ")[1] color = colors[ color_str] if color_str in colors else Color.default() else: text = argstr color = Color.default() await client.say(embed=Embed(color=color, description=text)) await client.delete_message(ctx.message)
def user_color_to_discord_color(color): if color is None: return Color.default() elif color == "random": return Color(random.randint(0x000000, 0xffffff)) else: return Color(color)
async def role(self, ctx: Context, *, role: Role): """Shows info about a role""" embed = Embed(ctx, title=t(ctx, "title", role=role.name), color=role.color) embed.add_field(name=t(ctx, "id"), value=role.id) if len(role.members) > 1: embed.add_field(name=t(ctx, "members"), value=str(len(role.members))) embed.add_field( name=t(ctx, "mentionable"), value=t(ctx, "mentionable_yes") if role.mentionable else t(ctx, "mentionable_no"), ) if role.color != Color.default(): embed.add_field( name=t(ctx, "color"), value=t( ctx, "color_value", hex=str(role.color), rgb=str(role.color.to_rgb()), ), ) embed.add_field(name=t(ctx, "created_at"), value=role.created_at) await ctx.send(embed=embed)
async def poll(ctx, col, arg2): try: if col == "red": embedcolor = Color.red() if col == "orange": embedcolor = Color.orange() if col == "yellow": embedcolor = Color.yellow() if col == "green": embedcolor = Color.green() if col == "blue": embedcolor = Color.blue() if col == "purple": embedcolor = Color.purple() if col == "black": embedcolor = Color.black() if col == "none": embedcolor = Color.default() embed=discord.Embed(title="POLL:", description=arg2, color=embedcolor) embed.set_footer(text="Vote by reacting") embedmsg = await ctx.send(embed=embed) await ctx.message.delete() await embedmsg.add_reaction("👍") await embedmsg.add_reaction("👎") print(Fore.GREEN+f'[>] Poll "{arg2}" sent!') except: print(Fore.RED+"[>] Poll failed") print(Fore.RESET)
async def get_user_embed_color(self, pdicog): color = await pdicog.config.user(self.ctx.author).color() if color is None: return Color.default() elif color == "random": return Color(random.randint(0x000000, 0xffffff)) else: return discord.Color(color)
def _set_color(card): if card == 'Free': return Color.light_grey() elif card == 'Common': return Color.lighter_grey() elif card == 'Rare': return Color.blue() elif card == 'Epic': return Color.purple() elif card == 'Legendary': return Color.orange() else: return Color.default()
async def announce(self, submission): if submission.is_self: desc_list = submission.selftext.split('\n') if len(desc_list) > 1: desc = desc_list[0] while not desc: desc_list.pop(0) desc = desc_list[0] i = -1 while desc[i] in ['.', '?', '!', ':', ';']: i -= 1 desc = desc[:(i + 1) or None] + '...' else: desc = desc_list[0] else: desc = 'Links to `{}`. [View the post instead.]({})'.format( submission.domain, "https://www.reddit.com" + submission.permalink) if len(desc) > 2048: last_valid_word_index = desc[:2048].rfind(' ') if last_valid_word_index == -1: last_valid_word_index = 2045 desc = desc[:last_valid_word_index] + '...' flair = submission.author_flair_css_class color = Color.default() author_icon = Embed.Empty if not flair: pass elif 'team' in flair: color = Color.blue() author_icon = 'https://cdn.discordapp.com/emojis/338117947241529344.png' elif 'mod' in flair: color = Color.green() author_icon = 'https://cdn.discordapp.com/emojis/338254475674255361.png' thumbnail = submission.thumbnail if 'http' not in thumbnail: thumbnail = Embed.Empty embed = self.module.create_discord_embed( title=submission.author, icon=author_icon, subtitle=submission.title, info=desc, subtitle_url=submission.url, color=color, thumbnail=thumbnail, footer='/r/{} - New Post'.format(self.module.subreddit_name)) return await self.send(embed=embed)
async def embed(ctx, *args): """ Sending embeded messages with color """ colors = { "red": Color.red(), "green": Color.green(), "gold": Color.gold(), "orange": Color.orange(), "blue": Color.blue() } if args: argstr = " ".join(args) if "-c " in argstr: text = argstr.split("-c ")[0] color_str = argstr.split("-c ")[1] color = colors[ color_str] if color_str in colors else Color.default() else: text = argstr color = Color.default() await bot.send_message(ctx.message.channel, embed=Embed(color=color, description=text)) await bot.delete_message(ctx.message)
def set_color(type): if type == 'Boost': return Color(0x95FF9C) elif type == 'Battle': return Color(0xFFDC83) elif type == 'Event': return Color(0x93C0FF) elif type == 'Trap': return Color(0xE28FFF) elif type == 'Gift': return Color(0xFC8BC6) elif type.startswith('Hyper'): return Color.orange() elif type == 'Character': return Color.lighter_grey() elif type == 'Enemy': return Color.red() else: return Color.default()
def get_top_role_color(member: Union[Member, User], *, fallback_color) -> Color: """ Tries to get member top role color and if fails returns fallback_color - This makes it work in DMs. Also if the top role has default role color then returns fallback_color. :param member: Member to get top role color from. If it's a User then default discord color will be returned. :param fallback_color: Color to use if the top role of param member is default color or if param member is discord.User (DMs) :return: discord.Color """ try: color = member.top_role.color except AttributeError: # Fix for DMs return fallback_color if color == Color.default(): return fallback_color else: return color
async def role(self, ctx: Context, *, role: Role): """Shows info about a role""" embed = Embed(ctx, title=role.name, color=role.color) embed.add_field(name="ID", value=role.id) if len(role.members) > 1: embed.add_field(name="Members", value=str(len(role.members))) embed.add_field(name="Mentionable", value="Yes" if role.mentionable else "No") if role.color != Color.default(): embed.add_field(name="Color", value=f"{role.color}, rgb{role.color.to_rgb()}") embed.add_field(name="Created at", value=role.created_at) await ctx.send(embed=embed)
async def announce(self, comment): desc_list = comment.body.split('\n') if len(desc_list) > 1: desc = desc_list[0] while not desc: desc_list.pop(0) desc = desc_list[0] i = -1 while desc[i] in ['.', '?', '!', ':', ';']: i -= 1 desc = desc[:(i + 1) or None] + '...' else: desc = desc_list[0] if len(desc) > 2048: last_valid_word_index = desc[:2048].rfind(' ') if last_valid_word_index == -1: last_valid_word_index = 2045 desc = desc[:last_valid_word_index] + '...' color = Color.default() author_icon = Embed.Empty flair = comment.author_flair_css_class if flair and 'team' in flair: color = Color.blue() author_icon = 'https://cdn.discordapp.com/emojis/338117947241529344.png' elif flair and 'mod' in flair: color = Color.green() author_icon = 'https://cdn.discordapp.com/emojis/338254475674255361.png' embed = self.module.create_discord_embed( title=comment.author, icon=author_icon, subtitle='Reply to ' + comment.submission.title, info=desc, subtitle_url="https://www.reddit.com" + (comment.permalink if type( comment.permalink) == str else comment.permalink()), color=color, footer='/r/{} - New Comment'.format(self.module.subreddit_name)) return await self.send(embed=embed)
async def message(content, clr=Color.default()): return await CLIENT.send_message(CHANNEL, embed=Embed(color=clr, description=content))
async def dungeonid(self, ctx, name, difficulty=None, *bad: str): """ Name: Name of Dungeon Difficulty: Difficulty level/name of floor (eg. for A1, "Bipolar Goddess") """ if bad: await ctx.send("Too many arguments. Make sure to surround all" " arguments with spaces in quotes.") return # load dbcog cog for database access dbcog = await self.get_dbcog() dungeon = await self.find_dungeon_from_name(ctx, name, dbcog.database.dungeon, difficulty) if dungeon is not None: # await ctx.send(format_overview(test_result)) current_stage = 0 pm_dungeon = [] # check for invades: invades = [] # print(dungeon.sub_dungeons[0].encounter_models) for enc_model in dungeon.sub_dungeons[0].encounter_models: behavior_test = MonsterBehavior() if (enc_model.enemy_data is not None) and (enc_model.enemy_data.behavior is not None): behavior_test.ParseFromString( enc_model.enemy_data.behavior) else: behavior_test = None # await ctx.send(format_overview(test_result)) # pm = process_monster(behavior_test, enc_model, db_cog.database) if enc_model.stage < 0: # pm.am_invade = True invades.append(enc_model) elif enc_model.stage > current_stage: current_stage = enc_model.stage floor = [enc_model] pm_dungeon.append(floor) else: pm_dungeon[current_stage - 1].append(enc_model) for f in pm_dungeon: if pm_dungeon.index(f) != (len(pm_dungeon) - 1): f.extend(invades) menu = DungeonMenu.menu() original_author_id = ctx.message.author.id test_list = ['1', '2', '3', '4'] # print(pm_dungeon[0]) view_state = DungeonViewState( original_author_id, 'DungeonMenu', name, Color.default(), pm_dungeon[0][0], dungeon.sub_dungeons[0].sub_dungeon_id, len(pm_dungeon), 1, len(pm_dungeon[0]), 0, int(dungeon.sub_dungeons[0].technical), dbcog.database, verbose=False) await ctx.send("EN: {}({})\nJP: {}({})".format( dungeon.name_en, dungeon.sub_dungeons[0].name_en, dungeon.name_ja, dungeon.sub_dungeons[0].name_ja)) message = await menu.create(ctx, view_state)
async def get_menu_default_data(self, ims): data = {'dbcog': await self.get_dbcog(), 'color': Color.default()} return data