【发布时间】:2020-12-05 05:48:35
【问题描述】:
您好,我正在尝试使用 Discord 的 API 将用户添加到我的公会。
我使用的范围是 Guild.Join、Identify 和 Guilds。 identify%20guilds%20guilds.join
网址是https://discordapp.com/api。
这是我的代码:
@staticmethod
def add_to_guild(access_token, userID):
url = f"https://discordapp.com/api/guilds/{guildId that I cant show}/members/{userID}"
botToken = "<Bot Token I can't SHow haha>"
headers = {
"Authorization" : f"Bot {botToken}",
'Content-Type': 'application/json'
}
payload = {
'access_token' : access_token
}
response = requests.put(url=url, data=payload, headers=headers)
print(response.text)
当我调用这个方法时,我收到这个错误:
{"message": "400: Bad Request", "code": 0}
我已经无数次浏览了 Discord 的文档,并在互联网上搜索无济于事。
有人可以帮忙吗?谢谢。
【问题讨论】:
-
我正在查看文档(tbh,我已经有一段时间没有这样做了,我忘记了很多),但是您是否仔细检查过该机器人是否具有适当的权限加人?
-
@downwithocp 是的。
-
我的下一个想法是检查用户 id 变量是否正确命名/调用。 discordpy.readthedocs.io/en/latest/api.html#discord.User