python - 如何在没有类型错误的情况下使用 add_reaction()?
问题描述
我正在尝试应朋友的要求制作口袋妖怪中心命令。计划是在用户对“A”表情符号 (:a:) 做出反应时继续对话,因此我试图让机器人首先对自己的消息做出反应。这是代码
@bot.command()
async def joy(ctx):
msg = await ctx.send(f'Welcome to our Pokémon Center!')
emoji = bot.get_emoji(706288524089098360)
await msg.add_reaction(msg,emoji)
每当我运行它时,我都会收到此错误:
TypeError: add_reaction() takes 2 positional arguments but 3 were given
解决方案
There is no need to put msg
as parameter of add_reaction()
, just use msg.add_reaction(emoji)
with a unicode emoji. Here is the doc for add_reaction()
The self
variable mustn't be specified, add_reaction()
gets it form msg
before the dot by himself in msg.add_reaction(emoji)
.
推荐阅读
- python - 使用python插入方法挑战
- powershell - WMIC 查询 Creationdate 以查找旧进程
- python - 如何从 Python 中的站点获取随机图像链接?
- php - 如何在不更改登录参数的情况下解决“LOGINREC 字段的名称太长(严重性 2)”
- java - 为什么最先启动的计时器最慢?
- c# - 如何动态显示 ItemsControl,如父 ItemsControl 的项目?
- python - 通过 python 算法将 Square Hald clut 转换为 Classic Hald clut
- android - 使用导航组件时从 BottomNavigationView 中移除 Badge
- python - PyQT5:在继续功能之前等待信号
- python - scrapy xpath :获取元素内的所有内部文本