TypeError: Cannot read properties of null (reading 'rest')
So I was create multi client Discord Bot Music. It was all fine for connecting the Discord Bot and initialize the manager with the bot. So right now I have two bot running.
The first bot with prefix
pp.
and the second one ri.
When I tried to play music with pp.
its all fine, the music started, but when I tried with the second one appear error like this.
TypeError: Cannot read properties of null (reading 'rest')
at new MoonlinkFilters (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Utils\MoonlinkFilters.js:21:33)
at new MoonlinkPlayer (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:46:24)
at Object.run (E:\Coding\GS Music\commands\Music\Play.js:24:62)
at module.exports (E:\Coding\GS Music\events\guild\messageCreate.js:50:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: Cannot read properties of null (reading 'rest')
at new MoonlinkFilters (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Utils\MoonlinkFilters.js:21:33)
at new MoonlinkPlayer (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:46:24)
at Object.run (E:\Coding\GS Music\commands\Music\Play.js:24:62)
at module.exports (E:\Coding\GS Music\events\guild\messageCreate.js:50:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

53 Replies
index.js
Event (ready)
Play cmd
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const { MoonlinkManager } = require("moonlink.js");
const { TOKEN, PREFIX } = require("./settings/config.js");
for (let i = 0; i < TOKEN.length; i++) {
const client = new Client({
shards: "auto",
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
allowedMentions: { parse: ["users", "roles"] },
});
client.config = require('./settings/config.js');
client.prefix = PREFIX[i];
client.token = TOKEN[i];
client.owner = client.config.OWNER_ID;
client.dev = client.config.DEV_ID;
client.color = client.config.EMBED_COLOR;
process.on('unhandledRejection', error => console.log(error));
process.on('uncaughtException', error => console.log(error));
// create lavalink client
client.manager = new MoonlinkManager(
[
{
host: "XXX",
port: 2333,
secure: false,
identifier: `NODE-${i}`,
password: "XXX"
}
],
{
/* Options */
clientId: client.user?.id,
clientName: client.user?.displayName,
doNotSaveToFiles: true,
autoResume: true
},
(guild, sPayload) => {
// Sending payload information to the server
client.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);
["aliases", "commands"].forEach(x => client[x] = new Collection());
["loadCommand", "loadEvent", "loadPlayer", "loadDatabase"].forEach(x => require(`./handlers/${x}`)(client));
client.login(client.token);
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const { MoonlinkManager } = require("moonlink.js");
const { TOKEN, PREFIX } = require("./settings/config.js");
for (let i = 0; i < TOKEN.length; i++) {
const client = new Client({
shards: "auto",
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
allowedMentions: { parse: ["users", "roles"] },
});
client.config = require('./settings/config.js');
client.prefix = PREFIX[i];
client.token = TOKEN[i];
client.owner = client.config.OWNER_ID;
client.dev = client.config.DEV_ID;
client.color = client.config.EMBED_COLOR;
process.on('unhandledRejection', error => console.log(error));
process.on('uncaughtException', error => console.log(error));
// create lavalink client
client.manager = new MoonlinkManager(
[
{
host: "XXX",
port: 2333,
secure: false,
identifier: `NODE-${i}`,
password: "XXX"
}
],
{
/* Options */
clientId: client.user?.id,
clientName: client.user?.displayName,
doNotSaveToFiles: true,
autoResume: true
},
(guild, sPayload) => {
// Sending payload information to the server
client.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);
["aliases", "commands"].forEach(x => client[x] = new Collection());
["loadCommand", "loadEvent", "loadPlayer", "loadDatabase"].forEach(x => require(`./handlers/${x}`)(client));
client.login(client.token);
module.exports = async (client) => {
client.initDelay = true
await client.manager.init(client.user?.id); // kalo ini sintink
console.log(`[INFO] - ${client.user.username} (${client.user.id}) is Ready!`);
client.user.setPresence({
status: 'online',
afk: false,
});
};
module.exports = async (client) => {
client.initDelay = true
await client.manager.init(client.user?.id); // kalo ini sintink
console.log(`[INFO] - ${client.user.username} (${client.user.id}) is Ready!`);
client.user.setPresence({
status: 'online',
afk: false,
});
};
let query = args.join(" ");
if (!query) return message.reply({ content: `:x: | Please provide a search query` });
const userChannel = message.member?.voice?.channel;
if (!userChannel) return message.reply({ content: `:x: | You need to join a voice channel first!` });
let player = message.client.manager.players.get(message.guild.id);
if (!player) player = message.client.manager.players.create({
guildId: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
autoPlay: false,
});
if (player.voiceChannel !== message.member.voice.channel.id) return message.reply({ content: `:x: | You need to be in the same voice channel as me!` });
if (!player.connected) {
// Connecting to the voice channel if not already connected
player.connect({
setDeaf: true,
setMute: false
});
}
let res = await message.client.manager.search({
query,
source: "youtube",
requester: message.author.id
});
if (res.loadType == "error") return message.reply({ content: `:x: ${res.data.message}` });
let query = args.join(" ");
if (!query) return message.reply({ content: `:x: | Please provide a search query` });
const userChannel = message.member?.voice?.channel;
if (!userChannel) return message.reply({ content: `:x: | You need to join a voice channel first!` });
let player = message.client.manager.players.get(message.guild.id);
if (!player) player = message.client.manager.players.create({
guildId: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
autoPlay: false,
});
if (player.voiceChannel !== message.member.voice.channel.id) return message.reply({ content: `:x: | You need to be in the same voice channel as me!` });
if (!player.connected) {
// Connecting to the voice channel if not already connected
player.connect({
setDeaf: true,
setMute: false
});
}
let res = await message.client.manager.search({
query,
source: "youtube",
requester: message.author.id
});
if (res.loadType == "error") return message.reply({ content: `:x: ${res.data.message}` });
harsh-harlequin•11mo ago
@1Lucas1.apk
:shy:
Oh yeah for information, I used this kind of this where I put for loop on index.js for multiple discord bot client at once, it is working before when I'm using other Lavalink player (its broken since the author discontinue the project) and now I'm moving to Moonlink. So when I move to Moonlink I just change this specific code.
and some command
// create lavalink client
client.manager = new MoonlinkManager(
[
{
host: "XXX",
port: 2333,
secure: false,
identifier: `NODE-${i}`,
password: "XXX"
}
],
{
/* Options */
clientId: client.user?.id,
clientName: client.user?.displayName,
doNotSaveToFiles: true,
autoResume: true
},
(guild, sPayload) => {
// Sending payload information to the server
client.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);
// create lavalink client
client.manager = new MoonlinkManager(
[
{
host: "XXX",
port: 2333,
secure: false,
identifier: `NODE-${i}`,
password: "XXX"
}
],
{
/* Options */
clientId: client.user?.id,
clientName: client.user?.displayName,
doNotSaveToFiles: true,
autoResume: true
},
(guild, sPayload) => {
// Sending payload information to the server
client.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);
Does the lavalink logs show that the two bots were connected successfully?
Yes, two bots were connected successfully.
I tried to console log when I init the client manager, both seems fine.
<ref *1> MoonlinkManager {
_events: [Object: null prototype] {
nodeConnect: [Function: bound ] AsyncFunction,
nodeCreate: [Function: bound ] AsyncFunction,
nodeDisconnect: [Function: bound ] AsyncFunction,
nodeError: [Function: bound ] AsyncFunction,
nodeReconnect: [Function: bound ] AsyncFunction,
playerCreate: [Function: bound ] AsyncFunction,
playerDestroy: [Function: bound ] AsyncFunction,
playerMove: [Function: bound ] AsyncFunction,
queueEnd: [Function: bound ] AsyncFunction,
trackEnd: [Function: bound ] AsyncFunction,
trackError: [Function: bound ] AsyncFunction,
trackStart: [Function: bound ] AsyncFunction,
trackStuck: [Function: bound ] AsyncFunction
},
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1143893863845613608',
_nodes: [
{
host: 'XX',
port: 2333,
secure: false,
identifier: 'NODE-1',
password: 'XX'
}
],
_SPayload: [Function (anonymous)],
players: PlayerManager { _manager: [Circular *1], cache: {}, voices: {} },
nodes: NodeManager {
initiated: true,
_manager: [Circular *1],
map: Map(1) { 'NODE-1' => [MoonlinkNode] }
},
version: '3.6.6',
options: {
clientId: '1143893863845613608',
clientName: 'Moonlink/3.6.6 (https://github.com/Ecliptia/moonlink.js)',
doNotSaveToFiles: true,
autoResume: true
},
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
}
<ref *1> MoonlinkManager {
_events: [Object: null prototype] {
nodeConnect: [Function: bound ] AsyncFunction,
nodeCreate: [Function: bound ] AsyncFunction,
nodeDisconnect: [Function: bound ] AsyncFunction,
nodeError: [Function: bound ] AsyncFunction,
nodeReconnect: [Function: bound ] AsyncFunction,
playerCreate: [Function: bound ] AsyncFunction,
playerDestroy: [Function: bound ] AsyncFunction,
playerMove: [Function: bound ] AsyncFunction,
queueEnd: [Function: bound ] AsyncFunction,
trackEnd: [Function: bound ] AsyncFunction,
trackError: [Function: bound ] AsyncFunction,
trackStart: [Function: bound ] AsyncFunction,
trackStuck: [Function: bound ] AsyncFunction
},
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1143893863845613608',
_nodes: [
{
host: 'XX',
port: 2333,
secure: false,
identifier: 'NODE-1',
password: 'XX'
}
],
_SPayload: [Function (anonymous)],
players: PlayerManager { _manager: [Circular *1], cache: {}, voices: {} },
nodes: NodeManager {
initiated: true,
_manager: [Circular *1],
map: Map(1) { 'NODE-1' => [MoonlinkNode] }
},
version: '3.6.6',
options: {
clientId: '1143893863845613608',
clientName: 'Moonlink/3.6.6 (https://github.com/Ecliptia/moonlink.js)',
doNotSaveToFiles: true,
autoResume: true
},
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
}
GG @ufibu, you just advanced to level 1!
due to the error, the filters class cannot access the rest class of the node
I'll take a look at the code and get back to you
Yeah, I tried with 3 bots, one of them is able to use play command, but the last two throw the error
Okay :hi:
moonlink.js/dist/src/@Utils
/MoonlinkFilters.js
could you put a console.log
in this file in node_modules
okay
on line 20
console.log(player.node)
Okay let me try
Its the @1Lucas1.apk first second bot and throw the error
<ref *2> MoonlinkNode {
_manager: <ref *1> MoonlinkManager {
_events: [Object: null prototype] {
nodeConnect: [Function: bound ] AsyncFunction,
nodeCreate: [Function: bound ] AsyncFunction,
nodeDisconnect: [Function: bound ] AsyncFunction,
nodeError: [Function: bound ] AsyncFunction,
nodeReconnect: [Function: bound ] AsyncFunction,
playerCreate: [Function: bound ] AsyncFunction,
playerDestroy: [Function: bound ] AsyncFunction,
playerMove: [Function: bound ] AsyncFunction,
queueEnd: [Function: bound ] AsyncFunction,
trackEnd: [Function: bound ] AsyncFunction,
trackError: [Function: bound ] AsyncFunction,
trackStart: [Function: bound ] AsyncFunction,
trackStuck: [Function: bound ] AsyncFunction
},
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [ [Object] ],
_SPayload: [Function (anonymous)],
players: PlayerManager { _manager: [Circular *1], cache: {}, voices: {} },
nodes: NodeManager {
initiated: true,
_manager: [Circular *1],
map: [Map]
},
version: '3.6.6',
options: {
clientId: '1093644762420088842',
clientName: 'Moonlink/3.6.6 (https://github.com/Ecliptia/moonlink.js)',
doNotSaveToFiles: true,
autoResume: true
},
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: <ref *1> MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
sessionId: 'w6k77o74rbfm2klp',
node: [Circular *2],
url: 'http://XXXX:2333/v4/'
},
info: {},
version: undefined,
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: 'w6k77o74rbfm2klp',
socket: MoonlinkWebSocket {
_events: [Object: null prototype] {
open: [Function: bound open],
close: [Function: bound close],
message: [Function: bound message] AsyncFunction,
error: [Function: bound error]
},
_eventsCount: 4,
_maxListeners: undefined,
url: URL {
href: 'ws://XXX:2333/v4/websocket',
origin: 'ws://XXX:2333',
protocol: 'ws:',
username: '',
password: '',
host: 'XXX:2333',
hostname: 'XXXX',
port: '2333',
pathname: '/v4/websocket',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
<ref *2> MoonlinkNode {
_manager: <ref *1> MoonlinkManager {
_events: [Object: null prototype] {
nodeConnect: [Function: bound ] AsyncFunction,
nodeCreate: [Function: bound ] AsyncFunction,
nodeDisconnect: [Function: bound ] AsyncFunction,
nodeError: [Function: bound ] AsyncFunction,
nodeReconnect: [Function: bound ] AsyncFunction,
playerCreate: [Function: bound ] AsyncFunction,
playerDestroy: [Function: bound ] AsyncFunction,
playerMove: [Function: bound ] AsyncFunction,
queueEnd: [Function: bound ] AsyncFunction,
trackEnd: [Function: bound ] AsyncFunction,
trackError: [Function: bound ] AsyncFunction,
trackStart: [Function: bound ] AsyncFunction,
trackStuck: [Function: bound ] AsyncFunction
},
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [ [Object] ],
_SPayload: [Function (anonymous)],
players: PlayerManager { _manager: [Circular *1], cache: {}, voices: {} },
nodes: NodeManager {
initiated: true,
_manager: [Circular *1],
map: [Map]
},
version: '3.6.6',
options: {
clientId: '1093644762420088842',
clientName: 'Moonlink/3.6.6 (https://github.com/Ecliptia/moonlink.js)',
doNotSaveToFiles: true,
autoResume: true
},
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: <ref *1> MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
sessionId: 'w6k77o74rbfm2klp',
node: [Circular *2],
url: 'http://XXXX:2333/v4/'
},
info: {},
version: undefined,
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: 'w6k77o74rbfm2klp',
socket: MoonlinkWebSocket {
_events: [Object: null prototype] {
open: [Function: bound open],
close: [Function: bound close],
message: [Function: bound message] AsyncFunction,
error: [Function: bound error]
},
_eventsCount: 4,
_maxListeners: undefined,
url: URL {
href: 'ws://XXX:2333/v4/websocket',
origin: 'ws://XXX:2333',
protocol: 'ws:',
username: '',
password: '',
host: 'XXX:2333',
hostname: 'XXXX',
port: '2333',
pathname: '/v4/websocket',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
options: {
port: '2333',
method: 'GET',
protocol: 'http:',
secure: false,
headers: [Object]
},
socket: Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_closeAfterHandlingError: false,
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: false,
_maxListeners: undefined,
_eventsCount: 4,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
timeout: 0,
parser: null,
_httpMessage: null,
[Symbol(async_id_symbol)]: 253,
[Symbol(kHandle)]: [TCP],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: Timeout {
_idleTimeout: -1,
_idlePrev: null,
_idleNext: null,
_idleStart: 2376,
_onTimeout: null,
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
[Symbol(refed)]: false,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 252,
[Symbol(triggerId)]: 0
},
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: true,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 1,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0
},
established: true,
closing: false,
headers: {
connection: 'Upgrade',
'sec-websocket-location': 'ws://XXX:2333/v4/websocket',
'session-resumed': 'false',
upgrade: 'WebSocket',
'lavalink-api-version': '4',
'sec-websocket-accept': '57N+rGbFAJ8FJCjfyVBV8rRzRN0=',
date: 'Thu, 25 Apr 2024 11:25:33 GMT'
},
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {},
calls: 0
}
null
options: {
port: '2333',
method: 'GET',
protocol: 'http:',
secure: false,
headers: [Object]
},
socket: Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_closeAfterHandlingError: false,
_events: [Object],
_readableState: [ReadableState],
_writableState: [WritableState],
allowHalfOpen: false,
_maxListeners: undefined,
_eventsCount: 4,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
timeout: 0,
parser: null,
_httpMessage: null,
[Symbol(async_id_symbol)]: 253,
[Symbol(kHandle)]: [TCP],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: Timeout {
_idleTimeout: -1,
_idlePrev: null,
_idleNext: null,
_idleStart: 2376,
_onTimeout: null,
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
[Symbol(refed)]: false,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 252,
[Symbol(triggerId)]: 0
},
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: true,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 1,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0
},
established: true,
closing: false,
headers: {
connection: 'Upgrade',
'sec-websocket-location': 'ws://XXX:2333/v4/websocket',
'session-resumed': 'false',
upgrade: 'WebSocket',
'lavalink-api-version': '4',
'sec-websocket-accept': '57N+rGbFAJ8FJCjfyVBV8rRzRN0=',
date: 'Thu, 25 Apr 2024 11:25:33 GMT'
},
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {},
calls: 0
}
null

Oh yeah the weird thing is, when I execute my code, sometime the music still continue playing
put this.rest = player.node?.rest
Okay
`
still same, now its spamming the console throwing error
TypeError: Cannot read properties of null (reading 'rest')
at MoonlinkPlayer.destroy (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:310:25)
at module.exports (E:\Coding\GS Music\events\guild\voiceStateUpdate.js:8:10)
at Client.emit (node:events:519:28)
at VoiceStateUpdate.handle (E:\Coding\GS Music\node_modules\discord.js\src\client\actions\VoiceStateUpdate.js:38:14)
at module.exports [as VOICE_STATE_UPDATE] (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\handlers\VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (E:\Coding\GS Music\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
TypeError: Cannot read properties of null (reading 'rest')
at MoonlinkPlayer.destroy (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:310:25)
at module.exports (E:\Coding\GS Music\events\guild\voiceStateUpdate.js:8:10)
at Client.emit (node:events:519:28)
at VoiceStateUpdate.handle (E:\Coding\GS Music\node_modules\discord.js\src\client\actions\VoiceStateUpdate.js:38:14)
at module.exports [as VOICE_STATE_UPDATE] (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\handlers\VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (E:\Coding\GS Music\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
TypeError: Cannot read properties of null (reading 'rest')
at MoonlinkPlayer.destroy (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:310:25)
at module.exports (E:\Coding\GS Music\events\guild\voiceStateUpdate.js:8:10)
at Client.emit (node:events:519:28)
at VoiceStateUpdate.handle (E:\Coding\GS Music\node_modules\discord.js\src\client\actions\VoiceStateUpdate.js:38:14)
at module.exports [as VOICE_STATE_UPDATE] (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\handlers\VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (E:\Coding\GS Music\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
TypeError: Cannot read properties of null (reading 'rest')
at MoonlinkPlayer.destroy (E:\Coding\GS Music\node_modules\moonlink.js\dist\src\@Entities\MoonlinkPlayer.js:310:25)
at module.exports (E:\Coding\GS Music\events\guild\voiceStateUpdate.js:8:10)
at Client.emit (node:events:519:28)
at VoiceStateUpdate.handle (E:\Coding\GS Music\node_modules\discord.js\src\client\actions\VoiceStateUpdate.js:38:14)
at module.exports [as VOICE_STATE_UPDATE] (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\handlers\VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (E:\Coding\GS Music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (E:\Coding\GS Music\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (E:\Coding\GS Music\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
in this line

on the way
So its like the node isn't registered?
moonlink.js/dist/src/@Entities
/MoonlinkPlayer.js
okay
Yes
put a console.log
de this.node
yeah its return null
GG @ufibu, you just advanced to level 2!
The other bot its able to play, the second one return null

not the same console.log
put , this.manager.nodes.map
where?
on entity?
in MoonlinkPlayer
console.log(this.node)
console.log(this.node)
console.log(this.nodes.map)
console.log(this.nodes.map)
this.manager.nodes.map

okay
like this? @1Lucas1.apk
this.manager.nodes.map((node) => {
console.log(node)
})
this.manager.nodes.map((node) => {
console.log(node)
})
at the
No
it's just
console.log(this.manager.modes.map)
oh
okay
Map(1) {
'NODE-0' => <ref *1> MoonlinkNode {
_manager: MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: [MoonlinkManager],
sessionId: '0u2ii90zqxrgdm34',
node: [Circular *1],
url: 'http://XXX:2333/v4/'
},
info: {
version: [Object],
buildTime: 1711779283712,
git: [Object],
jvm: '17.0.10',
lavaplayer: 'c8a8d821ea5ae92d8e618d67c1a26bf22a9c1e16-SNAPSHOT',
sourceManagers: [Array],
filters: [Array],
plugins: [Array]
},
version: 'b726aa2b065a7402d41b0482572ee81fbeed2c64-SNAPSHOT',
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: '0u2ii90zqxrgdm34',
socket: MoonlinkWebSocket {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
url: URL {},
options: [Object],
socket: [Socket],
established: true,
closing: false,
headers: [Object],
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {},
calls: 0
}
}
Map(1) {
'NODE-0' => <ref *1> MoonlinkNode {
_manager: MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: [MoonlinkManager],
sessionId: '0u2ii90zqxrgdm34',
node: [Circular *1],
url: 'http://XXX:2333/v4/'
},
info: {
version: [Object],
buildTime: 1711779283712,
git: [Object],
jvm: '17.0.10',
lavaplayer: 'c8a8d821ea5ae92d8e618d67c1a26bf22a9c1e16-SNAPSHOT',
sourceManagers: [Array],
filters: [Array],
plugins: [Array]
},
version: 'b726aa2b065a7402d41b0482572ee81fbeed2c64-SNAPSHOT',
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: '0u2ii90zqxrgdm34',
socket: MoonlinkWebSocket {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
url: URL {},
options: [Object],
socket: [Socket],
established: true,
closing: false,
headers: [Object],
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {},
calls: 0
}
}
did it just come from a bot?
its from console log that you told me
yes, but what about the other bot
This log is to know the nodes that were created to understand this problem further
Map(1) {
'NODE-0' => <ref *1> MoonlinkNode {
_manager: MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: [MoonlinkManager],
sessionId: 'mbl1v94aotkrm4ku',
node: [Circular *1],
url: 'http://XXX:2333/v4/'
},
info: {
version: [Object],
buildTime: 1711779283712,
git: [Object],
jvm: '17.0.10',
lavaplayer: 'c8a8d821ea5ae92d8e618d67c1a26bf22a9c1e16-SNAPSHOT',
sourceManagers: [Array],
filters: [Array],
plugins: [Array]
},
version: 'b726aa2b065a7402d41b0482572ee81fbeed2c64-SNAPSHOT',
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: 'mbl1v94aotkrm4ku',
socket: MoonlinkWebSocket {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
url: URL {},
options: [Object],
socket: [Socket],
established: true,
closing: false,
headers: [Object],
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {
frameStats: null,
players: 0,
playingPlayers: 0,
uptime: 92748307,
memory: [Object],
cpu: [Object]
},
calls: 0
}
}
Map(1) {
'NODE-0' => <ref *1> MoonlinkNode {
_manager: MoonlinkManager {
_events: [Object: null prototype],
_eventsCount: 13,
_maxListeners: undefined,
clientId: '1093644762420088842',
_nodes: [Array],
_SPayload: [Function (anonymous)],
players: [PlayerManager],
nodes: [NodeManager],
version: '3.6.6',
options: [Object],
initiated: true,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
reconnectTimeout: undefined,
reconnectAttempts: 1,
retryAmount: 6,
retryDelay: 120000,
resumeStatus: false,
host: 'XXX',
identifier: 'NODE-0',
password: 'XXX',
port: 2333,
secure: false,
regions: undefined,
http: 'http://XXX:2333/v4/',
rest: MoonlinkRestFul {
manager: [MoonlinkManager],
sessionId: 'mbl1v94aotkrm4ku',
node: [Circular *1],
url: 'http://XXX:2333/v4/'
},
info: {
version: [Object],
buildTime: 1711779283712,
git: [Object],
jvm: '17.0.10',
lavaplayer: 'c8a8d821ea5ae92d8e618d67c1a26bf22a9c1e16-SNAPSHOT',
sourceManagers: [Array],
filters: [Array],
plugins: [Array]
},
version: 'b726aa2b065a7402d41b0482572ee81fbeed2c64-SNAPSHOT',
resume: undefined,
resumed: false,
autoResume: true,
resumeTimeout: 30000,
sessionId: 'mbl1v94aotkrm4ku',
socket: MoonlinkWebSocket {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
url: URL {},
options: [Object],
socket: [Socket],
established: true,
closing: false,
headers: [Object],
partialMessage: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
state: 'READY',
stats: {
frameStats: null,
players: 0,
playingPlayers: 0,
uptime: 92748307,
memory: [Object],
cpu: [Object]
},
calls: 0
}
}
they are the same bot by id
1093644762420088842
1093644762420088842
Yes, because its NODE-0 supposed to be used by that clientId
I registered NODE-1 to used by another bot, but I don't know why here the other bot used NODE-0 instead of NODE-1
but they are the same application
but exactly, you are creating the same application twice
Yes, I creating the client twice or more not just for the manager but the discord client too.
GG @ufibu, you just advanced to level 3!
Can this problem caused by ready event that executed twice? @1Lucas1.apk , so its initiliaze twice
for the manager
it's not that
the problem is that he is not using the other tokens
is creating bot-1 twice
invest the bot-1 and bot-2
Oh yeah
Before
I tried to get the nodes
with manager.nodes.get
I able to get NODE-0
but I can't get NODE-1
I tried change the initilization, instead of on index.js I make loadManager.js on handlers
no more error, but there another problem here.
I could use the command on the other bot too now with no error, but after join the room, its automatically disconnected, and can't rejoined them
@1Lucas1.apk

nvm
still using the same node
harsh-harlequin•11mo ago
Did it work to re-join? If not, mind sharing join code?
No, its not working re-join, yeah I don't mind
Do you have liveshare extension on vscode?
harsh-harlequin•11mo ago
Yes but tbh I don't know how to use it
You just need to login to Github, and I will give the link, and you will see my code directly on your VSCode
harsh-harlequin•11mo ago
Could you share a gist instead? Feel free to send it in my DMs if anything