python - AttributeError:“HTTPClient”对象没有属性“send_files”
问题描述
我刚刚将我的不和谐机器人上传到了 heroku,除了一个之外,每个功能似乎都运行良好。有一个功能,我的机器人会抓取一个网站(使用 selenium)并拍摄一张桌子的照片并将其发送到我的一个不和谐房间。当我在本地运行机器人时它工作得很好,但是当我在 heroku 上运行机器人时尝试使用此功能时,我收到此错误消息。
AttributeError: 'HTTPClient' object has no attribute 'send_files'
news_room = rooms_id
taker = ScreenshotDriver.EventShooter() #this is my own class basically goes to the website and takes the picture
print("Taking pic")
await taker.TakePic()
cwd = os.getcwd()
file = discord.File(os.path.join(cwd,'web_screenshot.png'),filename='web_screenshot.png')
await client.get_channel(news_room).purge(limit=10)
await client.get_channel(news_room).send(file=file)
我确定这不是截屏的问题,因为它在本地工作,当它托管在 heroku 上时,它会进行房间清除,清除后我收到错误消息。所以基本上我的问题发生在这部分
await client.get_channel(news_room).send(file=file)
这是回溯
2021-04-07T00:04:37.597767+00:00 app[worker.1]: Taking pic
2021-04-07T00:04:56.614179+00:00 app[worker.1]: Ignoring exception in on_message
2021-04-07T00:04:56.616360+00:00 app[worker.1]: Traceback (most recent call last):
2021-04-07T00:04:56.616612+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-
packages/discord/client.py", line 327, in _run_event
2021-04-07T00:04:56.616615+00:00 app[worker.1]: await coro(*args, **kwargs)
2021-04-07T00:04:56.616620+00:00 app[worker.1]: File "Main.py", line 150, in on_message
2021-04-07T00:04:56.616625+00:00 app[worker.1]: await
client.get_channel(news_room).send(file=discord.File('web_screenshot.png'))
2021-04-07T00:04:56.616625+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-
packages/discord/abc.py", line 1032, in send
2021-04-07T00:04:56.616626+00:00 app[worker.1]: data = await state.http.send_files(channel.id, files=
[file], allowed_mentions=allowed_mentions,
2021-04-07T00:04:56.616655+00:00 app[worker.1]: AttributeError: 'HTTPClient' object has no attribute
'send_files'
解决方案
推荐阅读
- android - 将 android studio 从 3.2 更新到 3.3 后出现错误
- python - 无法安装python模块
- javascript - 当输入提供为“2018.1”时,如何获得针对季度的输出,例如“FY18 Q1”?
- python - 如何避免使用全局变量?
- .net - .Net Core 2.1 应用程序在使用 Docker 部署到 Heroku 时崩溃
- security - 如果我不存储密钥,加密我的 JWT 身份验证令牌客户端是否安全?
- angular - Angular:可移动对话框标题作为指令
- php - 我想在具有单个主键的一列中插入数据库中的多个数据
- python - FileNotFoundError: [Errno 2] No such file or directory: 'python': 'python' while running a python script
- spring-boot - 获取“访问被拒绝(用户是匿名的);重定向到身份验证入口点”。同时从 swagger ui 页面授权