fix(docker): Update environment variables and improve connection handling for Lavalink
This commit is contained in:
@@ -5,11 +5,19 @@ const loadErelaEvents = require('../structures/ErelaEvents'); // Import the Erel
|
||||
module.exports = {
|
||||
name: Events.ClientReady,
|
||||
once: true, // This event should only run once
|
||||
execute(client) {
|
||||
async execute(client) {
|
||||
logger.info(`Ready! Logged in as ${client.user.tag}`);
|
||||
|
||||
// Wait a moment before initializing Erela.js to give Lavalink time to start up
|
||||
// This is especially important in Docker environments
|
||||
await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second delay
|
||||
|
||||
// Initialize the Erela Manager once the client is ready
|
||||
try {
|
||||
// Log the actual connection details being used (without exposing the password)
|
||||
const node = client.manager.nodes[0];
|
||||
logger.info(`Attempting to connect to Lavalink at ${node.options.host}:${node.options.port} with identifier "${node.options.identifier}"`);
|
||||
|
||||
client.manager.init(client.user.id);
|
||||
logger.info(`Erela.js Manager initialized for user ID: ${client.user.id}`);
|
||||
|
||||
@@ -18,14 +26,19 @@ module.exports = {
|
||||
|
||||
} catch (error) {
|
||||
logger.error(`Failed to initialize Erela.js Manager: ${error.message}`);
|
||||
// Depending on requirements, you might want to exit or handle this differently
|
||||
// Try to reconnect after a delay if initialization fails
|
||||
setTimeout(() => {
|
||||
try {
|
||||
client.manager.init(client.user.id);
|
||||
logger.info(`Erela.js Manager initialization retry successful`);
|
||||
loadErelaEvents(client);
|
||||
} catch (retryError) {
|
||||
logger.error(`Retry initialization also failed: ${retryError.message}`);
|
||||
}
|
||||
}, 10000); // 10 second delay before retry
|
||||
}
|
||||
|
||||
// Placeholder for setting activity, etc.
|
||||
// client.user.setActivity('Music!', { type: 'LISTENING' });
|
||||
|
||||
// Note: Slash command registration is typically done in a separate deploy script,
|
||||
// not usually within the ready event for production bots.
|
||||
// We will create a deploy-commands.js script later.
|
||||
// Set activity status
|
||||
client.user.setActivity('Music | /play', { type: 'LISTENING' });
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user