(discord.py)如何检测自定义表情符号和默认表情符号

时间:2020-09-11 19:02:20

标签: python python-3.x discord discord.py discord.py-rewrite

我正在尝试执行一个enlarge命令,将表情符号变成png / gif格式

enter image description here

到目前为止,这是我的代码

@client.command()
async def enlarge(ctx, emoji: discord.PartialEmoji = None):
    if not emoji:
        await ctx.send("You need to provide an emoji!")
    else:
        await ctx.send(emoji.url)

这有效...但仅适用于自定义表情符号。该命令不会检测默认的表情符号,例如?或?。我已经尽了一切努力,但是我无法获取它来检测默认表情符号。有什么办法可以做到吗?

1 个答案:

答案 0 :(得分:0)

您可以使用emoji library作为默认表情符号。这是一个示例:

import emoji

@client.event
async def on_message(message):
    if emoji.emoji_count(message.content) > 0:
        await message.channel.send('You used a default emoji')

您可以看一下文档。