Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
fix: Added another botlist site to auto post stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbegby committed Jul 17, 2023
1 parent 13f0b02 commit 17d4295
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ BOTLIST_TOP_GG_API_TOKEN=
BOTLIST_DISCORD_BOT_LIST_COM_API_TOKEN=
BOTLIST_DISCORDS_COM_API_TOKEN=
BOTLIST_DISCORD_BOTS_GG_API_TOKEN=
BOTLIST_BOTLIST_ME_API_TOKEN=
BOTLIST_DISCORDLIST_GG_API_TOKEN=
16 changes: 9 additions & 7 deletions src/utils/postBotStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,41 @@ exports.postBotStats = (client) => {
/* eslint-disable camelcase */
const sites = [
{
name: 'top.gg',
hostname: 'top.gg',
path: `/api/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_TOP_GG_API_TOKEN
},
{
name: 'discordbotlist.com',
hostname: 'discordbotlist.com',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
method: 'POST',
body: { guilds: guildCount },
token: process.env.BOTLIST_DISCORD_BOT_LIST_COM_API_TOKEN
},
{
name: 'discords.com',
hostname: 'discords.com',
path: `/bots/api/bot/${process.env.DISCORD_CLIENT_ID}`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_DISCORDS_COM_API_TOKEN
},
{
name: 'discord.bots.gg',
hostname: 'discord.bots.gg',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
method: 'POST',
body: { guildCount: guildCount },
token: process.env.BOTLIST_DISCORD_BOTS_GG_API_TOKEN
},
{
name: 'discordlist.gg',
hostname: 'api.botlist.me',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_BOTLIST_ME_API_TOKEN
},
{
hostname: 'api.discordlist.gg',
path: `/v0/bots/${process.env.DISCORD_CLIENT_ID}/guilds?count=${guildCount}`,
method: 'PUT',
Expand All @@ -67,8 +69,8 @@ exports.postBotStats = (client) => {

let request = https.request(options, (res) => {
res.statusCode === 200
? logger.info(`Request to ${site.name}: statusCode: ${res.statusCode}`)
: logger.warn(`Request to ${site.name}: statusCode: ${res.statusCode}`);
? logger.info(`Request to ${site.hostname}: statusCode: ${res.statusCode}`)
: logger.warn(`Request to ${site.hostname}: statusCode: ${res.statusCode}`);
});

request.write(JSON.stringify(site.body));
Expand Down

0 comments on commit 17d4295

Please # to comment.