Discord.py 服务器角色命令,角色从下开始

时间:2021-04-23 17:32:22

标签: python discord discord.py

嗨,我执行了一个服务器角色命令,它运行良好,但顶部角色显示在下方。我的代码是这样的:

@bot.command(pass_context=True)
async def roles(ctx):
        guild = ctx.guild
        roles = [role for role in guild.roles if role != ctx.guild.default_role]
        embed = discord.Embed(title="Server Roles", description=f"\n \n".join([role.mention for role in roles]))
        await ctx.send(embed=embed)

我希望顶层角色从上层开始而不是从下层开始,我该怎么做?

如果有人帮助我,我会很高兴:)

1 个答案:

答案 0 :(得分:0)

db.vendors.aggregate([ { $lookup: { from: "vendorOrg", let: { vendorOrgId: "$vendorOrgId" }, pipeline: [ { $match: { $expr: { $eq: ["$$vendorOrgId", "$vendorOrgId"] }, status: "active" } }, { $project: { _id: 1, category: 1 } } ], as: "org" } }, { $unwind: "$org" }, { $group: { _id: "$org.category", vendors: { $push: { name: "$name", location: "$location", vendorOrgId: "$vendorOrgId" } } } }, { $group: { _id: null, vendors: { $push: { k: "$_id", v: "$vendors" } } } }, { $replaceRoot: { newRoot: { $arrayToObject: "$vendors" } } } ]) 类型有一个反向方法。因此,如果您编写 list,则 top 角色将是第一个。