我正在尝试创建一个包含“emoji”和 role.mention
的嵌入,以便将来能够对其进行编辑(以防我需要添加更多角色)。
每个“表情符号”及其对应的 role.id
都硬编码在现有的 dictionaries
中,如下例所示。我也将这些字典与我的 on_raw_reaction_add
一起使用。
我提前道歉,因为下面的代码不完整。我在逻辑和构建方面都遇到了麻烦,因此我们将不胜感激。提前非常感谢
groupNames = [("groupA"),
("groupB"),
("groupC")]
groupA = {
"❤️": 835836689821859870, #key is emoji in Unicode and value corresponds to an existing role.id
"?": 835836770129281034
}
@commands(name=test)
async def create_embed(self, ctx, group: str, *, title):
if group in (name[0] for name in groupNames):
groupID = group
desc = ""
help_text = ",".join([str(emoji), str(roleID) for emoji, roleID in groupID.items()])
for item in help_text:
role = ctx.guild.get_role(item["role"])
desc += f"{item['_id']}: {role.mention}\n"
#instead of help_text I thought of this approach but still don't know how to merge them
#emojis = ",".join([str(emoji) for emoji in groupID.keys()])
#roleIDs = ",".join([str(roleID) for roledID in groupID.values()])
embed = Embed(title=title, description=desc, inline=False)
msg = await ctx.send(embed=embed)
for emoji in help_text:
await msg.add_reaction(emoji["_id"])