Some more changed to the bot structure #2

Merged
snxraven merged 5 commits from MiTask/LinkUp-P2P-Chat:main into main 2024-06-08 17:11:17 -04:00
2 changed files with 2 additions and 7 deletions
Showing only changes of commit cd5cfb20a4 - Show all commits

View File

@ -61,15 +61,10 @@ loadCommands().then(commands => {
bot.on('onBotJoinRoom', () => { bot.on('onBotJoinRoom', () => {
console.log("Bot is ready!"); console.log("Bot is ready!");
bot.sendMessage(process.env.ON_READY_MESSAGE);
}); });
bot.joinChatRoom(); bot.joinChatRoom();
// Wait for 2 seconds for the bot to connect
setTimeout(() => {
// Send a message
bot.sendMessage(process.env.ON_READY_MESSAGE);
}, 2000); // Adjust the delay as necessary
}).catch(error => { }).catch(error => {
console.error('Error loading commands:', error); console.error('Error loading commands:', error);
}); });

View File

@ -27,8 +27,8 @@ class Client extends EventEmitter {
joinChatRoom() { joinChatRoom() {
this.discovery = this.swarm.join(this.topicBuffer, {client: true, server: true}); this.discovery = this.swarm.join(this.topicBuffer, {client: true, server: true});
this.discovery.flushed().then(() => { this.discovery.flushed().then(() => {
this.emit('onBotJoinRoom')
console.log(`Bot ${this.botName} joined the chat room.`); console.log(`Bot ${this.botName} joined the chat room.`);
this.emit('onBotJoinRoom');
}); });
} }