Skip to content

Commit

Permalink
keep alive for replit
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Oct 28, 2023
1 parent 7f800b3 commit 0d19cf0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ LAVALINK_NAME="Blacky" # Your lavalink name

LAVALINK_SECURE= "true" # true for secure lavalink

EEP_ALIVE= "false" # true for keep alive in https://replit.com

1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
yellow: 0xffff00,
main: 0x2f3136,
},
keepAlive: parseBoolean(process.env.KEEP_ALIVE) || false, // for https://replit.com keep alive bot 24/7
searchEngine: process.env.SEARCH_ENGINE || (SearchEngine.YouTube as SearchEngine),
maxPlaylistSize: parseInt(process.env.MAX_PLAYLIST_SIZE) || 100,
botStatus: process.env.BOT_STATUS || 'online', // online, idle, dnd, invisible
Expand Down
23 changes: 23 additions & 0 deletions src/plugin/plugins/keepAlive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import http from 'node:http';

import { Lavamusic } from '../../structures/index.js';
import { BotPlugin } from '../index.js';

const keepAlive: BotPlugin = {
name: 'KeepAlive Plugin',
version: '1.0.0',
author: 'Blacky',
initialize: (client: Lavamusic) => {
if (client.config.keepAlive) {
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(`I'm alive! Currently serving ${client.guilds.cache.size} guilds.`);
});
server.listen(3000, () => {
client.logger.info('Keep-Alive server is running on port 3000');
});
}
},
};

export default keepAlive;

0 comments on commit 0d19cf0

Please sign in to comment.