recruitment/cr.py
async def _clan_server_setup(self, ctx, member: discord.Member):
        """
            Setup nickname, and roles for a new member in a private clan server
        """
        guild = ctx.guild
        legend_servers = {
            757553323602608128: ["RY9QJU2", "Rising"],
            741928176779001948: ["9P2PQULQ", "Empire"],
            424929926844776462: ["80CC8", "Squad"],
            712090493399334913: ["PRCRJYCR", "Dragons Eight III"],
        }
        if guild.id not in legend_servers:
            return await ctx.send("Command cannot be used in this server")

        try:
            player_tags = self.tags.getAllTags(member.id)
        except AttributeError:
            return await ctx.send("Cannot connect to database. Please notify the devs.")
        clans_joined = []
        clan_roles = []
        discord_invites = []
        clan_nicknames = []
        ign = ""
        output_msg = ""

        if len(player_tags) == 0:
            return await ctx.send(
                "You must associate a tag with this member first using ``{}save #tag @member``".format(
                    ctx.prefix
                )
            )

        try:
            for tag in player_tags:
                player_data = await self.clash.get_player(tag)
                if player_data.clan is None:
                    player_clan_tag = ""
                else:
                    player_clan_tag = player_data.clan.tag.strip("#")

                if player_clan_tag == legend_servers[guild.id][0]:

                    ign = player_data.name
                    try:
                        await member.edit(nick=ign)
                    except discord.HTTPException:
                        await simple_embed(
                            ctx,
                            "I don't have permission to change nick for this user.",
                            False,
                        )
                    else:
                        output_msg += "Nickname changed to **{}**\n".format(ign)

                    clan_roles.append(legend_servers[guild.id][1])
                    try:
                        await self.discord_helper._add_roles(
                            member, clan_roles, reason="used nick"
                        )
                        output_msg += f"**{humanize_list(clan_roles)}** role added."
                    except discord.Forbidden:
                        await ctx.send(
                            "{} does not have permission to edit {}ΓÇÖs roles.".format(
                                ctx.author.display_name, member.display_name
                            )
                        )
                    except discord.HTTPException:
                        await ctx.send(
                            "Failed to add role {}.".format(humanize_list(clan_roles))
                        )
                    except InvalidRole:
                        await ctx.send(
                            "Server roles are not setup properly. "
                            "Please check if you have {} roles in server.".format(
                                humanize_list(clan_roles)
                            )
                        )
                    if output_msg:
                        return await simple_embed(ctx, output_msg, True)

            else:
                try:
                    player_data = await self.clash.get_player(player_tags[0])
                    ign = player_data.name + " | Guest"
                    await member.edit(nick=ign)
                except discord.HTTPException:
                    await simple_embed(
                        ctx,
                        "I don't have permission to change nick for this user.",
                        False,
                    )
                else:
                    output_msg += "Nickname changed to **{}**\n".format(ign)

                clan_roles.append("Guest")
                try:
                    await self.discord_helper._add_roles(
                        member, clan_roles, reason="used nick"
                    )
                    output_msg += f"**{humanize_list(clan_roles)}** role added. \n*If you are a part of {legend_servers[guild.id][1]}, please save the tag of your account in {legend_servers[guild.id][1]} too.*"
                except discord.Forbidden:
                    await ctx.send(
                        "{} does not have permission to edit {}ΓÇÖs roles.".format(
                            ctx.author.display_name, member.display_name
                        )
                    )
                except discord.HTTPException:
                    await ctx.send(
                        "Failed to add role {}.".format(humanize_list(clan_roles))
                    )
                except InvalidRole:
                    await ctx.send(
                        "Server roles are not setup properly. "
                        "Please check if you have {} roles in server.".format(
                            humanize_list(clan_roles)
                        )
                    )
                if output_msg:
                    return await simple_embed(ctx, output_msg, True)
        except clashroyale.RequestError:
            return await simple_embed(
                ctx, "Error: cannot reach Clash Royale Servers. Please try again later."
            )

            Setup nickname, and roles for a new member in a private clan server
        
Setup nickname, and roles for a new member in a private clan server
Setup nickname and roles for a new member in a private clan server
async def _clan_server_setup(self, ctx, member: discord.Member):
        guild = ctx.guild
        legend_servers = {
            757553323602608128: ["RY9QJU2", "Rising"],
            741928176779001948: ["9P2PQULQ", "Empire"],
            424929926844776462: ["80CC8", "Squad"],
            712090493399334913: ["PRCRJYCR", "Dragons Eight III"],
        }
        if guild.id not in legend_servers:
            return await ctx.send("Command cannot be used in this server")
        try:
            player_tags = self.tags.getAllTags(member.id)
        except AttributeError:
            return await ctx.send("Cannot connect to database. Please notify the devs.")
        clans_joined = []
        clan_roles = []
        discord_invites = []
        clan_nicknames = []
        ign = ""
        output_msg = ""
        if len(player_tags) == 0:
            return await ctx.send(
                "You must associate a tag with this member first using ``{}save #tag @member``".format(
                    ctx.prefix
                )
            )
        try:
            for tag in player_tags:
                player_data = await self.clash.get_player(tag)
                if player_data.clan is None:
                    player_clan_tag = ""
                else:
                    player_clan_tag = player_data.clan.tag.strip("#")
                if player_clan_tag == legend_servers[guild.id][0]:
                    ign = player_data.name
                    try:
                        await member.edit(nick=ign)
                    except discord.HTTPException:
                        await simple_embed(
                            ctx,
                            "I don't have permission to change nick for this user.",
                            False,
                        )
                    else:
                        output_msg += "Nickname changed to **{}**\n".format(ign)
                    clan_roles.append(legend_servers[guild.id][1])
                    try:
                        await self.discord_helper._add_roles(
                            member, clan_roles, reason="used nick"
                        )
                        output_msg += f"**{humanize_list(clan_roles)}** role added."
                    except discord.Forbidden:
                        await ctx.send(
                            "{} does not have permission to edit {}ΓÇÖs roles.".format(
                                ctx.author.display_name, member.display_name
                            )
                        )
                    except discord.HTTPException:
                        await ctx.send(
                            "Failed to add role {}.".format(humanize_list(clan_roles))
                        )
                    except InvalidRole:
                        await ctx.send(
                            "Server roles are not setup properly. "
                            "Please check if you have {} roles in server.".format(
                                humanize_list(clan_roles)
                            )
                        )
                    if output_msg:
                        return await simple_embed(ctx, output_msg, True)
            else:
                try:
                    player_data = await self.clash.get_player(player_tags[0])
                    ign = player_data.name + " | Guest"
                    await member.edit(nick=ign)
                except discord.HTTPException:
                    await simple_embed(
                        ctx,
                        "I don't have permission to change nick for this user.",
                        False,
                    )
                else:
                    output_msg += "Nickname changed to **{}**\n".format(ign)
                clan_roles.append("Guest")
                try:
                    await self.discord_helper._add_roles(
                        member, clan_roles, reason="used nick"
                    )
                    output_msg += f"**{humanize_list(clan_roles)}** role added. \n*If you are a part of {legend_servers[guild.id][1]}, please save the tag of your account in {legend_servers[guild.id][1]} too.*"
                except discord.Forbidden:
                    await ctx.send(
                        "{} does not have permission to edit {}ΓÇÖs roles.".format(
                            ctx.author.display_name, member.display_name
                        )
                    )
                except discord.HTTPException:
                    await ctx.send(
                        "Failed to add role {}.".format(humanize_list(clan_roles))
                    )
                except InvalidRole:
                    await ctx.send(
                        "Server roles are not setup properly. "
                        "Please check if you have {} roles in server.".format(
                            humanize_list(clan_roles)
                        )
                    )
                if output_msg:
                    return await simple_embed(ctx, output_msg, True)
        except clashroyale.RequestError:
            return await simple_embed(
                ctx, "Error: cannot reach Clash Royale Servers. Please try again later."
            )
async def _clan_server_setup ( self , ctx , member : discord . Member ) : guild = ctx . guild legend_servers = { 757553323602608128 : [ "RY9QJU2" , "Rising" ] , 741928176779001948 : [ "9P2PQULQ" , "Empire" ] , 424929926844776462 : [ "80CC8" , "Squad" ] , 712090493399334913 : [ "PRCRJYCR" , "Dragons Eight III" ] , } if guild . id not in legend_servers : return await ctx . send ( "Command cannot be used in this server" ) try : player_tags = self . tags . getAllTags ( member . id ) except AttributeError : return await ctx . send ( "Cannot connect to database. Please notify the devs." ) clans_joined = [ ] clan_roles = [ ] discord_invites = [ ] clan_nicknames = [ ] ign = "" output_msg = "" if len ( player_tags ) == 0 : return await ctx . send ( "You must associate a tag with this member first using ``{}save #tag @member``" . format ( ctx . prefix ) ) try : for tag in player_tags : player_data = await self . clash . get_player ( tag ) if player_data . clan is None : player_clan_tag = "" else : player_clan_tag = player_data . clan . tag . strip ( "#" ) if player_clan_tag == legend_servers [ guild . id ] [ 0 ] : ign = player_data . name try : await member . edit ( nick = ign ) except discord . HTTPException : await simple_embed ( ctx , "I don't have permission to change nick for this user." , False , ) else : output_msg += "Nickname changed to **{}**\n" . format ( ign ) clan_roles . append ( legend_servers [ guild . id ] [ 1 ] ) try : await self . discord_helper . _add_roles ( member , clan_roles , reason = "used nick" ) output_msg += f"**{humanize_list(clan_roles)}** role added." except discord . Forbidden : await ctx . send ( "{} does not have permission to edit {}ΓÇÖs roles.".fo r mat( ctx . author . display_name , member . display_name ) ) except discord . HTTPException : await ctx . send ( "Failed to add role {}." . format ( humanize_list ( clan_roles ) ) ) except InvalidRole : await ctx . send ( "Server roles are not setup properly. " "Please check if you have {} roles in server." . format ( humanize_list ( clan_roles ) ) ) if output_msg : return await simple_embed ( ctx , output_msg , True ) else : try : player_data = await self . clash . get_player ( player_tags [ 0 ] ) ign = player_data . name + " | Guest" await member . edit ( nick = ign ) except discord . HTTPException : await simple_embed ( ctx , "I don't have permission to change nick for this user." , False , ) else : output_msg += "Nickname changed to **{}**\n" . format ( ign ) clan_roles . append ( "Guest" ) try : await self . discord_helper . _add_roles ( member , clan_roles , reason = "used nick" ) output_msg += f"**{humanize_list(clan_roles)}** role added. \n*If you are a part of {legend_servers[guild.id][1]}, please save the tag of your account in {legend_servers[guild.id][1]} too.*" except discord . Forbidden : await ctx . send ( "{} does not have permission to edit {}ΓÇÖs roles.".fo r mat( ctx . author . display_name , member . display_name ) ) except discord . HTTPException : await ctx . send ( "Failed to add role {}." . format ( humanize_list ( clan_roles ) ) ) except InvalidRole : await ctx . send ( "Server roles are not setup properly. " "Please check if you have {} roles in server." . format ( humanize_list ( clan_roles ) ) ) if output_msg : return await simple_embed ( ctx , output_msg , True ) except clashroyale . RequestError : return await simple_embed ( ctx , "Error: cannot reach Clash Royale Servers. Please try again later." )
Setup nickname, and roles for a new member in a private clan server
Setup nickname and roles for a new member in a private clan server
"""
            Setup nickname, and roles for a new member in a private clan server
        """
self
ctx
member
discord.Member