Last active
May 29, 2021 13:52
-
-
Save dellybot/a46ba05746c29e9d664a2efc6c2fbb75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require("node-fetch"); | |
const botID = client.user.id; // You will probably need to change this | |
const URL = `https://api.discordextremelist.xyz/v2/bot/${botID}/stats`; | |
const reqHeaders = { | |
"Content-Type": "application/json", | |
"Authorization": "TOKEN" // Put your DELAPI token here | |
} | |
const reqBody = { | |
"guildCount": client.guilds.cache.size // You will probably need to change this | |
} | |
fetch(url, { method: "POST", headers: reqHeaders, body: JSON.stringify(reqBody)}) | |
.then((res) => { | |
return res.json() | |
}) | |
.then((json) => { | |
console.log(json); | |
}); |
You don't use backticks where you define the URL. This causes it to just say ${botID} instead of the actual bot ID.
Thank you for noticing, you're absolutely right, let me fix.
You specifed the url string wrong in the fetch(url, { method: "POST", headers: reqHeaders, body: JSON.stringify(reqBody)}) .then((res) => { return res.json()})
part.
According to your const URL = `https://api.discordextremelist.xyz/v2/bot/${botID}/stats`;
it should be fetch(URL, { method: "POST", headers: reqHeaders, body: JSON.stringify(reqBody)}) .then((res) => { return res.json()})
Basically it's case sensative.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't use backticks where you define the URL. This causes it to just say ${botID} instead of the actual bot ID.