Skip to content

Commit

Permalink
Consumed keepAlive.
Browse files Browse the repository at this point in the history
  • Loading branch information
moonstar-x committed Jan 27, 2022
1 parent 3082c52 commit 8b26546
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/settings.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 9 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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',
Expand All @@ -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) => {
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 8b26546

Please sign in to comment.