diff --git a/.env.example b/.env.example index 9d3a043f5..c711918be 100644 --- a/.env.example +++ b/.env.example @@ -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 + diff --git a/src/config.ts b/src/config.ts index 3c968e9c7..5d1aa646f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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 diff --git a/src/plugin/plugins/keepAlive.ts b/src/plugin/plugins/keepAlive.ts new file mode 100644 index 000000000..d578f4303 --- /dev/null +++ b/src/plugin/plugins/keepAlive.ts @@ -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;