我正在制作一个机器人,它可以通过请求更改url代码,但我尝试了一些方法,它只返回当前的invite代码
我的代码:
fetch('https://www.discord.com/api/v6/guilds/762359120031907871/vanity-url', {
method: 'POST',
headers: { 'Authorization': 'Bot ' + client.token, 'Content-Type': 'application/json'},
payload: JSON.stringify({
"code":"test458"
})
})
.then(res => res.json())
.then(json => { console.log(json)})它又回来了
{ code: 'cherrys', uses: 0 }我只想更改代码,但我不知道如何才能做到这一点,当我尝试使用用户令牌时,它会说
401: Unauthorized有人能帮我吗?
发布于 2021-08-28 10:29:30
Autorization头部的前缀Bot仅用于bot,如果您想使用用户token,则需要使用Bearer前缀,而不是bot的前缀。
fetch('https://www.discord.com/api/v6/guilds/762359120031907871/vanity-url', {
method: 'POST',
headers: { 'Authorization': 'Baerer ' + client.token, 'Content-Type': 'application/json'},
payload: JSON.stringify({
"code":"test458"
})
})
.then(res => res.json())
.then(json => { console.log(json)});https://stackoverflow.com/questions/64746804
复制相似问题