Async, non-blocking post to multiple Discord Bot stats using axios and ES8 async/await.
/**
This is just a snippet (assumes you've defined a Discord client, etc)
**/
async function postDiscordStats() {
const discordBots = axios({
method: 'post',
url: `https://discordbots.org/api/bots/${client.user.id}/stats`,
headers: {
Authorization: ''
},
data: {
server_count: client.guilds.size
}
})
const discordPw = axios({
method: 'post',
url: `https://bots.discord.pw/api/bots/${client.user.id}/stats`,
headers: {
Authorization: ''
},
data: {
server_count: client.guilds.size
}
})
const botlistSpace = axios({
method: 'post',
url: `https://botlist.space/api/bots/${client.user.id}`,
headers: {
Authorization: ''
},
data: {
server_count: client.guilds.size
}
})
const discordServices = axios({
method: 'post',
url: `https://discord.services/api/bots/${client.user.id}`,
headers: {
Authorization: ''
},
data: {
server_count: client.guilds.size
}
})
const [dbres, dpwres, bspaceres, dservres] = await Promise.all([discordBots, discordPw, botlistSpace, discordServices])
console.log(dbres, dpwres, bspaceres, dservres) // change as desired
}