尝试在类别中创建频道列表,然后拆分频道名称和表情。然后从中发送一个嵌入
问题在于,有时域名类似于#域名表情符号:
我使用-
来分割姓名,但在这种情况下我不能这样做,所以有没有办法检查表情符号是否是实际的表情符号?然后使用相同的表情符号,将反应添加到机器人发送的嵌入中
我在这里用评论标记了这些问题。有没有更好的方法来分割表情符号和域名
到目前为止,我有:
@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)
任何帮助都会很好!谢谢大家!
根据您的问题判断,您有两个可能的频道名称:
在这两种情况下,realm是第一个元素,emoji是最后一个元素,因此,您可以检查拆分的频道名称长度:
相关问题 更多 >
编程相关推荐