[英]How to convert string to discord.Emoji class in discord.py?
这是我的代码:
@client.command()
async def emote(ctx, *reaction:list):
await ctx.channel.purge(limit=1)
if len(reaction) == 0:
emotecommandHelp = discord.Embed(title= 'Help for the Emote command', description=f'{client.command_prefix}emote (text, no need for space)')
await ctx.send(embed = emotecommandHelp)
messagesID = await ctx.channel.history(limit=2).flatten() #earlier===> later
messagesID = messagesID[0]
message = await ctx.channel.fetch_message(messagesID.id)
if len(reaction) != 1:
reaction2 = [''.join(x) for x in reaction]
reaction = ''.join(reaction2)
reaction = list([x for x in reaction])
emotes = list(map(lambda szoveg : f":regional_indicator_{szoveg}:",reaction))
for i in emotes:
await message.add_reaction(i)
else:
emotes = list(map(lambda szoveg : f":regional_indicator_{szoveg}:",reaction[0]))
for i in emotes:
await message.add_reaction(i)
在这一点上,表情列表中充满了这种默认的表情,例如:
":regional_indicator_a:", ":regional_indicator_b:", ":regional_indicator_c:" ... 作为字符串
而且我不知道如何将它们添加为反应,因为我尝试的方式会引发错误。
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
你有什么想法如何解决这个问题吗? 我也没有身份证信息
<:emoji_name:emoji_id>
用于自定义表情符号。
您也可以通过Server.emojis找到discord.Emoji实例,然后将其转换为str。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.