如何让我的机器人在 discord.py 上使用更大版本的表情符号回复? [英] How do i make my bot reply with a bigger version of the emoji on discord.py?

查看:23
本文介绍了如何让我的机器人在 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 emojis
  • str for default unicode emojis checked against UNICODE_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 上使用更大版本的表情符号回复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆