【问题标题】:(discord.py) How can I detect custom and default emojis(discord.py) 如何检测自定义和默认表情符号
【发布时间】:2020-12-30 07:41:46
【问题描述】:

我正在尝试制作一个 enlarge 命令,它将表情符号变成这样的 png/gif 格式

这是我目前的代码

@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)

这可行...但仅适用于自定义表情符号。该命令不检测默认表情符号,例如 ????要么 ????。我已经尽我所能,但我无法让它检测默认表情符号。有什么办法可以做到吗?

【问题讨论】:

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


    【解决方案1】:

    您可以使用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')
    

    你可以看看文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-09
      • 2017-01-18
      • 1970-01-01
      • 2019-06-02
      • 2020-07-05
      • 2021-11-23
      • 1970-01-01
      相关资源
      最近更新 更多