python - 添加对消息的反应(discord.py)
问题描述
我想对在一个频道中发送的消息添加反应。我得到错误代码:
discord.errors.InvalidArgument: emoji argument must be str, Emoji, or Reaction not NoneType.
这是我的代码:
client = discord.Client()
if message.channel.id == 737668230012862514:
emoji = client.get_emoji(310177266011340803)
await message.add_reaction(emoji)
解决方案
line:emoji argument must be str, Emoji, or Reaction not NoneType
表示emoji
设置为None
,表示客户端找不到 id 的表情符号310177266011340803
。
从文档中可以看出,如果没有找到表情符号,则get_emoji
返回。None
请确保这310177266011340803
是一个有效的表情符号 ID,并且机器人可以访问表情符号所在的服务器。
要访问所有表情符号名称和 ID,您可以编写:
@client.event
async def on_ready():
for emoji in client.emojis:
print("Name:", emoji.name + ",", "ID:", emoji.id)
推荐阅读
- javascript - 以后如何对存储在 useState 中的对象使用方法?
- angular - 安装不同的 npm 包后,Angular Material Elements 在特定组件中停止工作
- makefile - CMake 构建 .sln 文件
- firebase - 如何测试 Firebase App Check 和 reCaptcha v3
- java - 新线程上的通量间隔滴答声
- serilog - 如何更改 Serilog 中特定日志事件的 LogLevel?
- scala - collectFirst:应用带有多个 case 子句的偏函数
- python - Pytorch 内存管理、CNN-LSTM 模型和 FHD 视频(内存不足问题)
- javascript - 如何使用js计算分段表单中的输入表单字段
- php - 它在数组中的位置