Can't see connection status and event in moonlink doesn't seem to work.

const { Client, Collection } = require('discord.js');
const { Manager } = require('moonlink.js');

module.exports = class BotClient extends Client {
constructor(option) {
super(option);
this.client = this;
this.moonlink = new Manager({
nodes: [
{
identifier: 'xxx',
host: 'xxx',
password: 'xxx',
port: 443,
secure: false,
},
],
options: {
// clientName: "MyApp/1.0.1"
},
sendPayload: (guildId, payload) => {
const guild = this.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
},
});
this.moonlink.on('nodeCreate', (node) => {
console.log(`${node.host} was connected, and the magic is in the air`);
});
this.on('raw', (data) => {
// Updating the Moonlink.js package with the necessary data
this.moonlink.packetUpdate(data);
});
}
async start(token) {
await this.login(token);
}
};
const { Client, Collection } = require('discord.js');
const { Manager } = require('moonlink.js');

module.exports = class BotClient extends Client {
constructor(option) {
super(option);
this.client = this;
this.moonlink = new Manager({
nodes: [
{
identifier: 'xxx',
host: 'xxx',
password: 'xxx',
port: 443,
secure: false,
},
],
options: {
// clientName: "MyApp/1.0.1"
},
sendPayload: (guildId, payload) => {
const guild = this.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
},
});
this.moonlink.on('nodeCreate', (node) => {
console.log(`${node.host} was connected, and the magic is in the air`);
});
this.on('raw', (data) => {
// Updating the Moonlink.js package with the necessary data
this.moonlink.packetUpdate(data);
});
}
async start(token) {
await this.login(token);
}
};
Why nodeCreate But I can't log out that I'm connected to lavalink? I don't understand why it doesn't work :((
5 Replies
dependent-tan
dependent-tan•7mo ago
you need to initialize it in ready event
client.once('ready', () => {
MoonlinkJS.init(client.user.id)
})
client.once('ready', () => {
MoonlinkJS.init(client.user.id)
})
if it is not changed i remember like that
nhut lam
nhut lamOP•7mo ago
const { ActivityType, Events } = require('discord.js');
const logger = require('~/utils/logger.js');

module.exports = {
name: Events.ClientReady,
execute: async (client) => {
client.moonlink.init(client.user.id);
console.log(client.moonlink);

logger.log(`${client.user.tag} is now online!`, 'client');
client.user.setPresence({
activities: [
{
name: 'Client Bot',
state: '/help | Bot',
type: ActivityType.Watching,
},
],
status: 'online',
});
},
};
const { ActivityType, Events } = require('discord.js');
const logger = require('~/utils/logger.js');

module.exports = {
name: Events.ClientReady,
execute: async (client) => {
client.moonlink.init(client.user.id);
console.log(client.moonlink);

logger.log(`${client.user.tag} is now online!`, 'client');
client.user.setPresence({
activities: [
{
name: 'Client Bot',
state: '/help | Bot',
type: ActivityType.Watching,
},
],
status: 'online',
});
},
};
I have initiated it but no response I have tried everything to solve this problem 😦
dependent-tan
dependent-tan•7mo ago
i dont really think, but is your intents has 'GuildVoiceStates' ?
nhut lam
nhut lamOP•7mo ago
already have I think the problem is in the moonlink event, it doesn't catch any event that has been called =)))
MEE6
MEE6•7mo ago
GG @nhut lam, you just advanced to level 1!

Did you find this page helpful?