async def clan_user_info(self, ctx: Context, *, username: str): try: player = rs3clans.Player(name=username, runemetrics=True) except ConnectionError: return await ctx.send( f"Houve um erro ao tentar conectar a API da Jagex. Tente novamente mais tarde." ) if not player.exists: return await ctx.send(f"Jogador '{player.name}' não existe.") if not player.clan: return await ctx.send( f"Jogador '{player.name}' não está em um clã.") user_clan = rs3clans.Clan(name=player.clan) member = user_clan.get_member(username) user_clan_exp = member.exp user_rank = member.rank display_username = player.name if self.bot.setting.show_titles: if player.suffix: display_username = f"{player.name} {player.title}" else: display_username = f"{player.title} {player.name}" user_url_name = player.name.replace(" ", "%20") user_url_clan = player.clan.replace(" ", "%20") icon_url = f"https://secure.runescape.com/m=avatar-rs/{user_url_name}/chat.png" runeclan_url = f"https://runeclan.com/user/{user_url_name}" clan_banner_url = f"http://services.runescape.com/m=avatar-rs/l=3/a=869/{user_url_clan}/clanmotif.png" embed_title = "RuneClan" rank_header = "__Rank__" clan_header = "__Clã__" exp_header = "__Exp no Clã__" total_exp_header = "__Exp Total__" private_profile_header = "Indisponível - Perfil Privado" rank_emoji = self.bot.setting.clan_settings[user_rank]['Emoji'] user_rank = self.bot.setting.clan_settings[user_rank]['Translation'] clan_info_embed = discord.Embed( title=embed_title, description="", color=discord.Colour.dark_blue(), url=runeclan_url, ) clan_info_embed.set_author(icon_url=icon_url, name=display_username) clan_info_embed.set_thumbnail(url=clan_banner_url) clan_info_embed.add_field(name=clan_header, value=player.clan) clan_info_embed.add_field(name=rank_header, value=f"{user_rank} {rank_emoji}") clan_info_embed.add_field(name=exp_header, value=f"{user_clan_exp:,}") if player.private_profile: clan_info_embed.add_field(name=total_exp_header, value=private_profile_header, inline=False) else: clan_info_embed.add_field(name=total_exp_header, value=f"{player.exp:,}") return await ctx.send(content=None, embed=clan_info_embed)
async def clan_detail_info(self, ctx: Context, *, clan_name: str): try: clan = rs3clans.Clan(name=clan_name, set_exp=True) except ConnectionError: return await ctx.send( f"Houve um erro ao tentar conectar a API da Jagex. Tente novamente mais tarde." ) except rs3clans.ClanNotFoundError: return await ctx.send(f"O clã '{clan_name}' não existe.") clan_leader = None for member in clan: if member.rank == 'Owner': clan_leader = member.name clan_url = clan.name.replace(' ', '%20') clan_embed = discord.Embed( title=clan.name, color=discord.Color.green(), url=f'http://services.runescape.com/m=clan-home/clan/{clan_url}') clan_embed.set_author(name='RuneClan', url=f'https://runeclan.com/clan/{clan_url}') clan_embed.set_thumbnail( url= f'http://services.runescape.com/m=avatar-rs/{clan_url}/clanmotif.png' ) clan_embed.add_field(name="Exp Total", value=f'{clan.exp:,}') clan_embed.add_field(name="Membros", value=str(clan.count)) clan_embed.add_field(name="Líder", value=clan_leader) clan_embed.add_field(name="Exp Média por Membro", value=f'{clan.avg_exp:,.0f}') return await ctx.send(embed=clan_embed)
async def ranks(self, ctx: Context): exp_general = 500_000_000 exp_captain = 225_000_000 exp_lieutenant = 125_000_000 exp_seargent = 50_000_000 rank_emoji = { 'Recruit': self.bot.setting.clan_settings['Recruit']['Emoji'], 'Corporal': self.bot.setting.clan_settings['Corporal']['Emoji'], 'Sergeant': self.bot.setting.clan_settings['Sergeant']['Emoji'], 'Lieutenant': self.bot.setting.clan_settings['Lieutenant']['Emoji'], 'Captain': self.bot.setting.clan_settings['Captain']['Emoji'], 'General': self.bot.setting.clan_settings['General']['Emoji'], } ranks_embed = discord.Embed( title="__Ranks a Atualizar__", description=" ", ) found = False clan = rs3clans.Clan(self.bot.setting.clan_name, set_exp=False) clan_members = reversed([member for member in clan]) for member in clan_members: if len(ranks_embed.fields) >= 20: await ctx.send( 'Muitos ranks a serem atualizados, enviando apenas os 20 primeiros.' ) break if member.rank == 'Recruit': ranks_embed.add_field( name=member.name, value= f"Recruta {rank_emoji['Recruit']} ❯ Cabo {rank_emoji['Corporal']}\n" f"**__Exp:__** {member.exp:,}\n{separator}", inline=False) found = True elif member.exp >= exp_general and member.rank == 'Captain': ranks_embed.add_field( name=member.name, value= f"Capitão {rank_emoji['Captain']} ❯ General {rank_emoji['General']}\n" f"**__Exp:__** {member.exp:,}\n{separator}", inline=False) found = True elif member.exp >= exp_captain and member.rank == 'Lieutenant': ranks_embed.add_field( name=member.name, value= f"Tenente {rank_emoji['Lieutenant']} ❯ Capitão {rank_emoji['Captain']}\n" f"**__Exp:__** {member.exp:,}\n{separator}", inline=False) found = True elif member.exp >= exp_lieutenant and member.rank == 'Sergeant': ranks_embed.add_field( name=member.name, value= f"Sargento {rank_emoji['Sergeant']} ❯ Tenente {rank_emoji['Lieutenant']}\n" f"**__Exp:__** {member.exp:,}\n{separator}", inline=False) found = True elif member.exp >= exp_seargent and member.rank == 'Corporal': ranks_embed.add_field( name=member.name, value= f"Cabo {rank_emoji['Corporal']} ❯ Sargento {rank_emoji['Sergeant']}\n" f"**__Exp:__** {member.exp:,}\n{separator}", inline=False) found = True if not found: ranks_embed.add_field( name="Nenhum Rank a ser atualizado no momento :)", value=separator, inline=False) return await ctx.send(embed=ranks_embed)
async def authenticated_user(self, ctx: Context, *, user_name: str): """ Searches Authenticated User, first by Ingame Name, then by Discord Name, then by Discord Id """ lower_name = user_name.lower() with self.bot.db_session() as session: member: User = session.query(User).filter( func.lower(User.ingame_name).contains(lower_name)).first() if not member: member = session.query(User).filter( func.lower( User.discord_name).contains(lower_name)).first() if not member: member = session.query(User).filter( func.lower(User.discord_id).contains(lower_name)).first() if not member: # Search User using one of his old names ingame_name: IngameName = session.query(IngameName).filter( func.lower(IngameName.name).contains(lower_name)).first() if ingame_name: member = session.query(User).filter_by( id=ingame_name.user).first() if not member: return await ctx.send( f'Não existe um usuário autenticado com o usuário in-game ou do Discord \'{user_name}\'.' ) nb_space = '\u200B' embed = discord.Embed(title=f"Usuário Autenticado", description=nb_space, color=discord.Color.green()) last_update = member.updated.strftime('%d/%m/%y - %H:%M') warning_date = 'N/A' if member.warning_date: warning_date = member.warning_date.strftime('%d/%m/%y - %H:%M') disabled = 'Sim' if member.disabled else 'Não' name_list = [ ingame_name.name for ingame_name in member.ingame_names ] ingame_names = ', '.join(name_list) if name_list else 'Nenhum' clan = rs3clans.Clan('Atlantis') player: rs3clans.ClanMember = clan.get_member(member.ingame_name) embed.add_field(name='Nome In-game', value=member.ingame_name) embed.add_field(name='Desabilitado?', value=disabled) embed.add_field(name='Nome Discord', value=member.discord_name) embed.add_field(name='ID Discord', value=member.discord_id) embed.add_field(name='ID Database', value=member.id) embed.add_field(name='Último update', value=last_update) embed.add_field(name='Data de Warning', value=warning_date) if player: player_rank = ( f'{self.bot.setting.clan_settings[player.rank]["Translation"]} ' f'{self.bot.setting.clan_settings[player.rank]["Emoji"]}') embed.add_field(name='Exp no Clã', value=f'{player.exp:,}') embed.add_field(name='Rank no Clã', value=player_rank) else: embed.add_field(name='No Clã?', value='Não') embed.add_field(name='Nomes In-Game Anteriores', value=ingame_names, inline=False) embed.set_author( name="RuneClan", url= f"https://runeclan.com/user{member.ingame_name.replace(' ', '%20')}" ) await ctx.author.send(embed=embed) await ctx.message.add_reaction('✅')