首页 > 解决方案 > 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'

标签: pythonherokudiscord.py

解决方案


推荐阅读