Код:
import requests
channelID = Заполнено валидным айди канала
headers = {"Токен есть если что"}
with open('text.txt', 'r', encoding='utf-8') as file:
lines = [line.strip() for line in file]
for lines in lines:
requests.post(f"https://discord.com/api/v9/channels/{channelID}/messages", headers = headers, json = {"content": lines})
Выходит такая вот ошибка при попытке запуска:
Traceback (most recent call last):
File "d:\Desktop\Новая папка\discordbot.py", line 10, in <module>
requests.post(f"https://discord.com/api/v9/channels/{channelID}/messages", headers = headers, json = {"content": lines})
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\sessions.py", line 575, in request prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\sessions.py", line 486, in prepare_request
p.prepare(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\models.py", line 369, in prepare
self.prepare_headers(headers)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\models.py", line 489, in prepare_headers
for header in headers.items():
^^^^^^^^^^^^^
AttributeError: 'set' object has no attribute 'items'