check server status and change server

my idea is to add 10 lavalink servers and each one can have max 100 bots on it how can i make the code check if the server is at 100 bot or not and if it is how can the bot disconnect and re connect to another one
18 Replies
ugly-tan
ugly-tan•2y ago
Do you want to make it through IP checking? I'd recommend NodeLink for that case It's easier to edit
Turki
TurkiOP•2y ago
can i connect and check?
ugly-tan
ugly-tan•2y ago
What do you mean, connect to..?
Turki
TurkiOP•2y ago
client.moon.on('nodeCreate', (node) => {
console.log(`${node.host} was connected\n${node.stats.players} - ${node.isConnected}`);
});
client.moon.on('nodeCreate', (node) => {
console.log(`${node.host} was connected\n${node.stats.players} - ${node.isConnected}`);
});
i get in the log
15|part_15 | lavalinkIP was connected
15|part_15 | 0 - undefined
15|part_15 | lavalinkIP was connected
15|part_15 | 0 - undefined
@1Lucas1.apk
ugly-tan
ugly-tan•2y ago
You're confusing nodelink with lavalink; with lavalink, it will need java knowledge. The issue about connecting I am not sure, I don't use moonlink, but I recommend debugging with console.log
Turki
TurkiOP•2y ago
some bots don't connect to lavalink when i run the command play test it reply with the music name and everything but the music don't start @1Lucas1.apk
ugly-tan
ugly-tan•2y ago
You're probably missing ws event calling moonlink's function to send voice info to lavalink
1Lucas1.apk
1Lucas1.apk•2y ago
Could you add an event?
client.moon.on('nodeRaw', (node, data) => console.log(`${node.host}: ${data}`)
client.moon.on('nodeRaw', (node, data) => console.log(`${node.host}: ${data}`)
Just to see if you are receiving information from lavalink And could you tell me which version of lavalink and nodejs are you using?
Turki
TurkiOP•2y ago
@1Lucas1.apk
lavaserverip:
{
op: 'stats',
frameStats: null,
players: 0,
playingPlayers: 0,
uptime: 49132243,
memory: {
free: 113145728,
used: 268535936,
allocated: 381681664,
reservable: 1027604480
},
cpu: {
cores: 16,
systemLoad: 0.06566145417787596,
lavalinkLoad: 0.0001515187573424245
}
}
lavaserverip:
{
op: 'stats',
frameStats: null,
players: 0,
playingPlayers: 0,
uptime: 49132243,
memory: {
free: 113145728,
used: 268535936,
allocated: 381681664,
reservable: 1027604480
},
cpu: {
cores: 16,
systemLoad: 0.06566145417787596,
lavalinkLoad: 0.0001515187573424245
}
}
nodejs 16 lavalink beta this when i start a song
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353909408, position: 0, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353909410, position: 0, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353914407, position: 5100, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353919407, position: 10100, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353909408, position: 0, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353909410, position: 0, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353914407, position: 5100, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
lavaserverip:
{
op: 'playerUpdate',
state: { time: 1699353919407, position: 10100, connected: true, ping: 0 },
guildId: '1133935011813392444'
}
MEE6
MEE6•2y ago
GG @Turki, you just advanced to level 1!
1Lucas1.apk
1Lucas1.apk•2y ago
Update nodejs to v18 or above When you download nodejs v18 could you test again Because I did some tests before, in the version below node 18 some errors were occurring
Turki
TurkiOP•2y ago
i well try it
1Lucas1.apk
1Lucas1.apk•2y ago
@Turki Hello, I made some corrections And to check if it's working In your project's package.json You look for moonlink.js in dependency and replace it with "moonlink.js": "https://github.com/1Lucas1apk/moonlink.js", And npm install, and test again
ugly-tan
ugly-tan•2y ago
(Que eu saiba, era pra ser 1Lucas1apk/moonlink.js)
1Lucas1.apk
1Lucas1.apk•2y ago
Funcionar assim também eu testei indagora
ugly-tan
ugly-tan•2y ago
Ah sim
1Lucas1.apk
1Lucas1.apk•2y ago
As in this form in package.json in this first image Change the version using the repository link Nem é segredo mais Tem tanta print dele
1Lucas1.apk
1Lucas1.apk•2y ago
No description

Did you find this page helpful?