From 8b26546f61f8c40a2ed048bdd7109f8fe1ae67a9 Mon Sep 17 00:00:00 2001 From: moonstar-x Date: Thu, 27 Jan 2022 11:00:02 -0500 Subject: [PATCH] Consumed keepAlive. --- config/settings.json.example | 3 ++- src/app.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/settings.json.example b/config/settings.json.example index cc95ebbf..ab275e45 100644 --- a/config/settings.json.example +++ b/config/settings.json.example @@ -8,5 +8,6 @@ "testing_guild_id": null, "provider_type": "level", "redis_url": "redis://ip:port", - "enable_tts_channels": false + "enable_tts_channels": false, + "enable_keep_alive": false } diff --git a/src/app.js b/src/app.js index 9a83b93d..eeae4170 100644 --- a/src/app.js +++ b/src/app.js @@ -4,6 +4,7 @@ const RedisDataProvider = require('@greencoast/discord.js-extended/dist/provider const LevelDataProvider = require('@greencoast/discord.js-extended/dist/providers/LevelDataProvider').default; const TTSClient = require('./classes/extensions/TTSClient'); const { locales } = require('./locales'); +const { keepAlive } = require('./utils/keep-alive'); const { DISCONNECT_TIMEOUT } = require('./common/constants'); const pkg = require('../package.json'); @@ -21,7 +22,8 @@ const config = new ConfigProvider({ TESTING_GUILD_ID: null, PROVIDER_TYPE: 'level', REDIS_URL: null, - ENABLE_TTS_CHANNELS: false + ENABLE_TTS_CHANNELS: false, + ENABLE_KEEP_ALIVE: false }, types: { TOKEN: 'string', @@ -33,7 +35,8 @@ const config = new ConfigProvider({ TESTING_GUILD_ID: ['string', 'null'], PROVIDER_TYPE: 'string', REDIS_URL: ['string', 'null'], - ENABLE_TTS_CHANNELS: 'boolean' + ENABLE_TTS_CHANNELS: 'boolean', + ENABLE_KEEP_ALIVE: 'boolean' }, customValidators: { PROVIDER_TYPE: (value) => { @@ -120,6 +123,10 @@ client.once('ready', async() => { client.ttsChannelHandler.initialize(); } + if (config.get('ENABLE_KEEP_ALIVE')) { + keepAlive({ port: process.env.PORT || 3000 }); + } + client.on('guildCreate', async(guild) => { await client.initializeDependenciesForGuild(guild); });