Привет. У меня проблема с отображением вставки. Функция когда команда List
вызывается, бот отправит список ролей в категориях. Однако, когда команда вызывается, это то, что я получаю
Это не тот результат, на который я надеялся. Кажется, здесь отсутствует colours:
. Я покажу, как я пытаюсь это сделать в своем коде.
@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)
colours = ['Blue', 'Yellow', 'Pink', 'Black']
Games = ['LoL', 'WoW']
if ctx.message.channel == intros:
pass
else:
if ctx.message.channel == botroom:
message = '\n**Colours:**\n' # Colour roles category here
for role in colours: # if roles are colours list this under this category.
message += '\n{} **({})**'.format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])]))
message += ''
for role in Games: #if roles are games list this under this category.
message = '\n**Games:**\n' # Games roles category here
message += '\n{} **({})**'.format(role, len([member for member in guild.members if ([r for r in member.roles if r.name == role])]))
message += ''
embed = discord.Embed(title="Roles List", description=message.format(), colour=0x0080c0)
embed.set_footer(text="Tip: to add a role from the list type the command !add/remove followed by the role.")
await ctx.send(embed=embed)
else:
await ctx.send('You can only use this command in {}.'.format(botroom.mention))
Я не уверен, что идет не так, правильно ли я использую форматирование. Помощь будет оценена.