繁体   English   中英

使用 NodeJS 提出 Discord 请求(更改虚荣心)

[英]Make Discord Request With NodeJS (Change Vanity Discord)

我正在制作一个可以通过请求更改 url 代码的机器人,但我尝试了一些东西,它只返回当前的邀请代码

我的代码:

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

有人可以帮我吗?

Autorization 标头上的前缀Bot仅适用于 Bot,如果要使用用户令牌,则需要使用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)});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM