通过discord中的请求发送消息时出现错误401

问题描述 投票:0回答:1

这是我的代码:

import requests

header = {"authorization": '[Redacted]'
         }
payload = {'content': "Test"}

r = requests.post(
  'https://discord.com/api/v9/channels/[Redacted]/messages',
                data=payload,
                headers=header
            )
print(r.status_code)

我想通过我的帐户(而不是通过机器人)向特定频道发送消息,上面提供的代码不久前对我来说工作得很好,但现在它返回错误代码 401 [未经授权的请求]

尝试寻找解决方案和原因,找不到任何原因,因为我只是不好T-T,所以我在这里

很抱歉,如果这是一个愚蠢的问题,请提前感谢您的帮助

python automation discord
1个回答
0
投票

检查授权token是否正确,并写入:

header = {"Authorization": '[Redacted]'
© www.soinside.com 2019 - 2024. All rights reserved.