Hi I'm having an issue trying to display a symbol that denotes a role that can be mentioned in Discord. I'm currently using discord.py and they use role.mentionable which is a Boolean
https://discordpy.readthedocs.io/en/rewrite/api.html#discord.Role.mentionable
What I'm trying to accomplish and failing to do is being able to set add :bell: in front of the role that is mentionable while :nobell: for the roles that are not.
I get the error AttributeError: 'str' object has no attribute 'mentionable'
Here is the code I'm working with:
@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 ---"
if ctx.message.channel == intros:
pass
else:
if ctx.message.channel == botroom:
title = '**Hey {}, here is a categorised list of roles you can add:**'.format(author.display_name)
embed = discord.Embed(title=title.format(), colour=0x0080c0)
embed.add_field(name="\n**__Notifications__**", value="roles with a :bell: at the beginning of them are @mentionable - when applied you may recieve notifications.\n\n", 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#
#Colours
Colours = ['Blue', 'Green', 'Orange', 'Yellow', 'Pink', 'Purple']
Colours.sort(key=str.lower)
embed.add_field(name='**__Colour Roles__**', value='\n'.join([":bell: {} **({})**" if role.mentionable in Colours else ":no_bell: {} **({})**".format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])])) for role in Colours]))
await ctx.send(embed=embed)
else:
await ctx.send('You can only use this command in {}.'.format(botroom.mention))
More specifically the error is on this line within the code
embed.add_field(name='**__Colour Roles__**', value='\n'.join([":bell: {} **({})**" if role.mentionable in Colours else ":no_bell: {} **({})**".format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])])) for role in Colours]))
I'm not sure what to do from here. Help much appreciated.
Edit: reply @Kanasaki Torisowa
Colours = ['Blue', 'Green', 'Orange', 'Yellow', 'Pink', 'Purple']
Colours.sort(key=str.lower)
for role in guild.roles:
if role.mentionable in Colours == True:
embed.add_field(name='**__Colour Roles__**', value='\n'.join(["{} **({})**".format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])])) for role in Colours]))
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)