我试图使用python请求发送dm,这包括创建dm通道,然后发送dm。不,我不能使用一个库,因为它正在与一个web应用程序交互。
import requests
import json as js
token = “token”
def dm(id, token):
headers = {"Authorization": f"Bot {token}"}
json = {"recipient_id": id}
r = requests.post("https://discord.com/api/v9/users/@me/channels",headers=headers, data=json)
print(r.text)
cid = js.loads(r.text)["id"]
json = {"content": token}
rr = requests.post(f"https://discord.com/api/v9/channels/{cid}/messages",headers=headers, data=json)```
No matter what I do this ends up with a 401 Unauthorized error.
Thanks发布于 2022-01-27 21:08:10
401的意思是未经授权,而由于您在这里设置的无效令牌,您将得到此信息:
token = “token”
https://stackoverflow.com/questions/70885589
复制相似问题