【发布时间】:2020-11-16 18:16:15
【问题描述】:
尝试创建一个类别中的频道列表,然后拆分频道名称和表情符号。然后从中发送嵌入。
问题在于,有时领域名称类似于#realm-name-emoji:
我使用- 来拆分名称,但在这种情况下我不能这样做,所以有没有办法检查表情符号是否是实际的表情符号?然后使用相同的表情符号,为机器人发送的嵌入添加一个反应。
我在这里用评论标记了这些问题。拆分表情符号和域名是否有更好的选择?
到目前为止,我有这个:
@commands.command()
async def checkin(self, ctx):
if ctx.guild.id != "guild id":
return
else:
category = discord.utils.get(ctx.guild.categories, id="my ID here")
checkinem = discord.Embed(title='Realms Channels')
for channel in category.channels:
realm, emoji = channel.name.split('-') #issue here
checkinem.add_field(name=realm, value=emoji, inline=False)
checkinmsg = await ctx.send(embed=checkinem)
for channel in category.channels:
realm, emoji = channel.name.split('-') #issue here
await checkinmsg.add_reaction(emoji=emoji)
任何帮助都会很棒!谢谢!
【问题讨论】:
-
您可以尝试使用
unicodedata.lookup(str),但对于某些像:white_check_mark:这样的表情符号将不起作用
标签: python discord.py