diff --git a/README.md b/README.md index 57a9b3e0..18a05bf7 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,6 @@ CLOUDFLARE_API_KEY= CLOUDFLARE_EMAIL= CLOUDFLARE_ACCOUNT_ID= CLOUDFLARE_BLOCK_IP_LIST_ID= -DISCORD_PLACE_API_KEY= LOGTAIL_SOURCE_TOKEN= LEMON_SQUEEZY_WEBHOOK_SECRET= LEMON_SQUEEZY_API_KEY= @@ -160,7 +159,6 @@ DISCORD_BOT_GET_APPROXIMATE_GUILD_COUNT_API_SECRET= | `CLOUDFLARE_EMAIL` | Cloudflare email. | | `CLOUDFLARE_ACCOUNT_ID` | Cloudflare account ID. | | `CLOUDFLARE_BLOCK_IP_LIST_ID` | Cloudflare block IP list ID. | -| `DISCORD_PLACE_API_KEY` | discord.place API key. (not required) | | `DISCORD_PLACE_INSTATUS_API_KEY` | discord.place Instatus API key. (not required) | | `LOGTAIL_SOURCE_TOKEN` | Logtail source token. (not required) | | `LEMON_SQUEEZY_WEBHOOK_SECRET` | Lemon Squeezy webhook secret. (not required) | @@ -177,7 +175,6 @@ DISCORD_BOT_GET_APPROXIMATE_GUILD_COUNT_API_SECRET= > - The `CLOUDFLARE_TURNSTILE_SECRET_KEY` is used for verifying the Turnstile token. We use Cloudflare Turnstile for ensuring that the user is a human and not a bot on the website. Refer to the [Cloudflare Turnstile documentation](https://developers.cloudflare.com/turnstile/get-started/#get-a-sitekey-and-secret-key) to get your Turnstile secret key. > - The `CLOUDFLARE_API_KEY`, `CLOUDFLARE_EMAIL`, and `CLOUDFLARE_ACCOUNT_ID` values are required for interacting with the Cloudflare API. You can get the API key from the Cloudflare dashboard. > - The `CLOUDFLARE_BLOCK_IP_LIST_ID` is used for blocking IP addresses within the Cloudflare firewall. Refer to the [Cloudflare WAF documentation](https://developers.cloudflare.com/waf/tools/lists/create-dashboard/) to create a list. After creating the list, you can get the list ID from the URL. (usually should be in the end of the URL) -> - The `DISCORD_PLACE_API_KEY` is used for authenticating requests to the discord.place API endpoints. This is not required for self-hosting. We use this for update our bot's command count every day on the website. > - The `DISCORD_PLACE_INSTATUS_API_KEY` is used for authenticating requests to the discord.place Instatus API endpoints. This is not required for self-hosting. We use this for displaying the current status of the discord.place on the homepage. You can get this from the Instatus dashboard. Refer to the [Instatus API documentation](https://instatus.com/help/api) for more information. > - The `LOGTAIL_SOURCE_TOKEN` is used for sending logs to Logtail. This is not required for self-hosting. We actually not use this in our production environment. But we wanted to keep this in the repository for future use. > - The `LEMON_SQUEEZY_WEBHOOK_SECRET` is used for verifying the Lemon Squeezy webhook. This is not required for self-hosting. We use Lemon Squeezy for our payment system. Refer to the [Lemon Squeezy documentation](https://docs.lemonsqueezy.com/help/webhooks) for more information. diff --git a/server/.example.env b/server/.example.env index c2d5b563..8001b3f3 100644 --- a/server/.example.env +++ b/server/.example.env @@ -38,7 +38,6 @@ CLOUDFLARE_BLOCK_IP_LIST_ID= # Discord Place -DISCORD_PLACE_API_KEY= DISCORD_PLACE_INSTATUS_API_KEY= # Logtail diff --git a/server/src/client.js b/server/src/client.js index 4c5066cd..fae4ba57 100644 --- a/server/src/client.js +++ b/server/src/client.js @@ -253,25 +253,19 @@ module.exports = class Client { } async updateBotStats() { - if (!process.env.DISCORD_PLACE_API_KEY) return logger.warn('API key is not defined. Please define DISCORD_PLACE_API_KEY in your environment variables.'); - - const url = `https://api.discord.place/bots/${client.user.id}/stats`; - const data = { - command_count: client.commands.size - }; - - try { - const response = await axios.patch(url, data, { - headers: { - authorization: process.env.DISCORD_PLACE_API_KEY + const bot = await Bot.findOne({ id: client.user.id }); + if (!bot) return logger.error(`${client.user.id} bot not found in the Bot collection. Skipping update bot stats.`); + + await Bot.updateOne({ id: client.user.id }, { + $set: { + command_count: { + value: client.commands.size, + updatedAt: new Date() } - }); + } + }); - if (response.status === 200) logger.info('Bot stats updated on Discord Place.'); - else logger.error(`Failed to update bot stats: ${response.data}`); - } catch (error) { - logger.error('Failed to update bot stats:', error); - } + logger.info('Updated bot stats.'); } async checkExpiredBlockedIPs() {