【发布时间】:2020-11-23 20:14:04
【问题描述】:
我正在尝试使用 Discord 的 API(使用 access_token)获取特定聊天室中当前用户的角色。我已经通过文档进行了公平的查看,但看不到如何做到这一点。例如,向https://discordapp.com/api/users/@me 发出获取请求会按预期提供基本用户信息。然后我尝试了以下内容,但没有任何运气:
https://discordapp.com/api/users/@me/guilds/${guild.id}/roles
这是我正在使用的代码的 sn-p:
....get access token then
.then(info => {
console.log(info)
fetch(`https://discordapp.com/api/users/@me`, {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}).then(response => response.json())
.then(info => {
console.log(info)
})
})
有什么想法吗?
为了澄清,用户使用 discord 登录,我的应用程序会收到一个用户访问令牌,然后我试图用它来获取用户在特定 discord 房间中的角色。
【问题讨论】:
标签: javascript api discord