in Education by
Hi I'm having some issues showing lists in my embed correctly. I'm trying to get my roles to under one list title here is the issue I'm having with how my lists are displaying themselves in the embed. It seems each role is being duplicated under the list title. I've tried inline=True this doesn't seem to fix the issue. #--- Below is the list command --- @commands.command(pass_context=True, no_pm=True, name='list', aliases=['roles', 'role']) async def _list(self, ctx): """List of all available roles """ guild = ctx.message.guild author = ctx.message.author botroom = self.bot.get_channel(555844758778544160) intros = self.bot.get_channel(485381365366390796) #--- Role list Categories ---" Colours = ['Blue', 'Green', 'Orange', 'Yellow', 'Pink', 'Purple'] Colours.sort(key=str.lower) Games = ['LoL', 'WoW', 'Overwatch'] Games.sort(key=str.lower) Platforms = ['PC', 'Xbox', 'PS4', 'Nintendo Switch'] Platforms.sort(key=str.lower) if ctx.message.channel == intros: pass else: if ctx.message.channel == botroom: title = '**Hey {}, here is a list of roles you can add:**'.format(author.display_name) embed = discord.Embed(title=title.format(), colour=0x0080c0) embed.add_field(name="**Have a role suggestion?**", value="If you can't find the role you want but would like to see it added to the roles list please tell us in <#555371532390760473>.", inline=False) embed.set_footer(text="Tip: to add a role from the list type the command !add/remove followed by the role.") #Lets start embed roles list below# for role in Games: embed.add_field(name="**Game Roles**", value="\n{} **({})**".format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])]))) for role in Platforms: embed.add_field(name="**Plaforms Roles**", value="\n{} **({})**".format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])]))) await ctx.send(embed=embed) else: await ctx.send('You can only use this command in {}.'.format(botroom.mention)) Role in lists are not displaying as they should. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You're currently adding the categories once for each item in the category. Instead, you want to add each category once, listing all the roles underneath it. You can also get the role object and access len(role.members) directly: def role_name_to_summary(ctx, name): role = get(ctx.guild.roles, name=name) if not role: return None return f"{role.name} **({len(role.members)})**" embed.add_field(name="**Game Roles**", value="\n".join(filter(None, [role_name_to_summary(ctx, name) for name in Games]))

Related questions

0 votes
    Hi I'm having an issue trying to display a symbol that denotes a role that can be mentioned in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    Hi Everyone I'm Having This Two Columns: Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Hi Everyone I'm Having This Two Columns: Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have some trouble to correctly embed images in html/php email. My .php file just sends out a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I am trying to fit some (numpy) data into python skLearn modules, but keep getting error messages. When ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I have multiple xlsx files with data in it that i want to import to separate dataframes in Python. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Convert pandas DateTimeIndex to Unix Time? (7 answers) Closed 3 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    Let's say I have the following code: from types import coroutine @coroutine def stop(): yield 1 async ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have multiple xlsx files with data in it that i want to import to separate dataframes in Python. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I used the function for gower distance from this link: https://sourceforge.net/projects/gower-distance- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have two Dataframes : DF1(That i've just resampled): Mi_pollution.head(): Sensor_ID Time_Instant ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 3, 2022 in Education by JackTerrance
0 votes
    I want to have root mean squared of gradient boosting algorithm but when I want to print it, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I want to have root mean squared of gradient boosting algorithm but when I want to print it, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I'm trying to do the Udacity mini project and I've got the latest version of the SKLearn library ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
...