本文介绍了如何让我的机器人在 discord.py 上使用更大版本的表情符号回复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am trying to make a command that makes the bot respond to your message (!big :emoji:) with that emoji just bigger. Is there a way to do this?
UPDATE: Is there a way to do this with all emojis and not just custom ones?
解决方案
You can make a command with an argument specified as discord.Emoji
or str
discord.Emoji
is for custom emojisstr
for default unicode emojis checked againstUNICODE_EMOJI
Here is a example using Emoji.url
and UNICODE_EMOJI
# from typing import Union
# from emoji import UNICODE_EMOJI
@bot.command()
async def big(ctx, emoji: Union[discord.Emoji, str] = None):
# custom emoji
if isinstance(emoji, discord.Emoji):
await ctx.send(emoji.url)
# default emoji
elif isinstance(emoji, str) and emoji in UNICODE_EMOJI:
await ctx.send(emoji)
else:
await ctx.send("Not a valid emoji")
这篇关于如何让我的机器人在 discord.py 上使用更大版本的表情符号回复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!