Bot disconnects

When the bot plays it music (for me its a radio station) and when I disconnect the bot throughout discord itself "Disconnect <botname>" the bot doesn't re-connect, also doesn't re-connect when re-entering the command. I have to restart the entire discord bot for it. Is there a different way for this?
138 Replies
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I didn't quite understand what you meant, could you explain better?
Justin
JustinOPβ€’2y ago
Basically, I have my play command that plays a radio station through my URL. It succesfully plays, and it works. But when I disconnect the bot throughout the discord menu, it doesn't want to re-connect. Re-entering the /play command doesn't let it re-connect either. A little snippet I can show.
Justin
JustinOPβ€’2y ago
You understand now?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I understood On the play command, the connet is like
If(player.connected) player.connect();
If(player.connected) player.connect();
If connected is not being updated, I will have to check the package codes to find my possible error
Justin
JustinOPβ€’2y ago
I could rq share you the code I have right now. I have already player.connected. https://sourceb.in/wY1P0JM68n
1Lucas1.apk
1Lucas1.apkβ€’2y ago
So, I will analyze the moonlink.js codes, and in a few minutes I will publish a version correcting this
Justin
JustinOPβ€’2y ago
Ah, thanks. Please mention me when the version has been released πŸ‘
1Lucas1.apk
1Lucas1.apkβ€’2y ago
He is well
Justin
JustinOPβ€’2y ago
What?
MEE6
MEE6β€’2y ago
GG @Justin, you just advanced to level 1!
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I meant, okay
1Lucas1.apk
1Lucas1.apkβ€’2y ago
GitHub
moonlink.js/src/@Moonlink/MoonlinkManager.ts at v2 Β· 1Lucas1apk/moo...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. Support Server: https://discord.gg/xQq2A8vku3 - 1Lucas1...
1Lucas1.apk
1Lucas1.apkβ€’2y ago
The part appears to be working correctly when the player is disconnected. I'm just checking to make sure I didn't add any additional code to the bot
Justin
JustinOPβ€’2y ago
I see you are testing right now, but you have to force disconnect the bot, not wait until the bot is done playing. Play a song, force disconnect the discord bot, and then try playing it again. Then it happend by me.
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Which version of nodejs do you use?
Justin
JustinOPβ€’2y ago
v18.18.0
genetic-orange
genetic-orangeβ€’2y ago
But if we had a nodejs below 18.18.0 wouldn't this still work?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Below versions 18, many errors were occurring As data was not being treated correctly in some classes
genetic-orange
genetic-orangeβ€’2y ago
Ok cool no worries, thought I would ask about that.
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Now I want to understand why the playerDisconnected is not being issued
genetic-orange
genetic-orangeβ€’2y ago
Would the playerDisconnected still work even if the bot was removed from the voice channel? πŸ€”
1Lucas1.apk
1Lucas1.apkβ€’2y ago
There is a way to make it destroy the player using a Discord.js event Wait quickly
client.on('voiceStateUpdate', (oldState, newState) => {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
}
}
});
client.on('voiceStateUpdate', (oldState, newState) => {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
}
}
});
foreign-sapphire
foreign-sapphireβ€’2y ago
(i am the leader of this project) do we try this?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Could you test this code?
genetic-orange
genetic-orangeβ€’2y ago
Cool it works
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Have a great day πŸ™‚
genetic-orange
genetic-orangeβ€’2y ago
Would this work away from client.on? so creating its own file?
Justin
JustinOPβ€’2y ago
Basically an 'external file'
genetic-orange
genetic-orangeβ€’2y ago
Just cause we are facing an err when trying it.
foreign-sapphire
foreign-sapphireβ€’2y ago
ye
Justin
JustinOPβ€’2y ago
Cause this is my external file,
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.player.get(guildId);

if (player) {
player.destroy();
}
}
},
};
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.player.get(guildId);

if (player) {
player.destroy();
}
}
},
};
And then it returns with TypeError: Cannot read properties of undefined (reading 'player')
foreign-sapphire
foreign-sapphireβ€’2y ago
that's probably because moon is not defined
1Lucas1.apk
1Lucas1.apkβ€’2y ago
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
}
}
},
};
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
}
}
},
};
foreign-sapphire
foreign-sapphireβ€’2y ago
you copied our code, congrats
genetic-orange
genetic-orangeβ€’2y ago
Yes, if we do that its sending any err don't worry :)
MEE6
MEE6β€’2y ago
GG @Connor200024, you just advanced to level 1!
genetic-orange
genetic-orangeβ€’2y ago
I will figure this out :D thanks for the fix and letting us know the issue.
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Have a great day πŸ™‚
genetic-orange
genetic-orangeβ€’2y ago
Same to you :)
foreign-sapphire
foreign-sapphireβ€’2y ago
πŸ’€ πŸ’€ πŸ’€ πŸ’€
1Lucas1.apk
1Lucas1.apkβ€’2y ago
🀑
genetic-orange
genetic-orangeβ€’2y ago
Cool guy Lucas is ;)
Justin
JustinOPβ€’2y ago
So how to use it in an external file?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I don't understand, from what I saw, it exports the client, and you already assigned a value to client.moon, from what I saw in the command If the external file imports the client, client.moon will go with it
foreign-sapphire
foreign-sapphireβ€’2y ago
it imports the client
MEE6
MEE6β€’2y ago
GG @Jul 🌹, you just advanced to level 1!
Justin
JustinOPβ€’2y ago
It keeps giving me this error, TypeError: Cannot read properties of undefined (reading 'players')
foreign-sapphire
foreign-sapphireβ€’2y ago
it cant find client.moon.player or players
1Lucas1.apk
1Lucas1.apkβ€’2y ago
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
console.log(client.moon)
/*
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
} */
}
},
};
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
console.log(client.moon)
/*
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
} */
}
},
};
See what returns from client.moon
Justin
JustinOPβ€’2y ago
alright one sec
MEE6
MEE6β€’2y ago
GG @Justin, you just advanced to level 2!
Justin
JustinOPβ€’2y ago
undefined
1Lucas1.apk
1Lucas1.apkβ€’2y ago
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
console.log(client)
/*
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
} */
}
},
};
module.exports = {
name: "voiceStateUpdate",
async execute(client, oldState, newState) {
if (oldState.member.user.bot && oldState.channel && !newState.channel) {
const guildId = oldState.guild.id;
console.log(client)
/*
let player = client.moon.players.get(guildId);

if (player) {
player.destroy();
} */
}
},
};
See if the client returns
Justin
JustinOPβ€’2y ago
client returns
1Lucas1.apk
1Lucas1.apkβ€’2y ago
How do you assign moonlink.js to client.moon? 🀑
Justin
JustinOPβ€’2y ago
I just copied over your code from the Github Repo, and it worked :NM_peepoShrugSmile:, so i don't know how i assigned them
1Lucas1.apk
1Lucas1.apkβ€’2y ago
If you use something like an event folder And like storing the cache in a map or collections in Discord.js, which is the same thing as Map You must ensure that the value is assigned before receiving the customer when loading the events Because the client that was exported to the events may be without client.moon! @Justin All values ​​must be assigned before playing on the Discord.js map or collections Summed up: When you add a class to a Map object and then add a new function to the class, that function will not automatically be reflected in Map objects that have already been created using that class. This is because Map objects store a reference to the class that was used when they were created, and any subsequent changes to the class do not affect existing Map objects.
Justin
JustinOPβ€’2y ago
Different question now, is it possible to change the messages of Moonlink.js?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Like this? I didn't understand what you meant
foreign-sapphire
foreign-sapphireβ€’2y ago
HAHA 😭 😭 😭 😭 ASK CHATGPT
1Lucas1.apk
1Lucas1.apkβ€’2y ago
You speak something random that I don't quite understand
foreign-sapphire
foreign-sapphireβ€’2y ago
WDYMMM It's pretty clear
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Moonlink.js issues with gpt are very flawed
foreign-sapphire
foreign-sapphireβ€’2y ago
No Bruh Okay
genetic-orange
genetic-orangeβ€’2y ago
When you guys mean change messages what messages?
foreign-sapphire
foreign-sapphireβ€’2y ago
he wants to change the messages from the moonlink.js ill show u
foreign-sapphire
foreign-sapphireβ€’2y ago
No description
genetic-orange
genetic-orangeβ€’2y ago
Yah we must be able to edit that If thats pos
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Just edit the content It's the basics of Discord.js
genetic-orange
genetic-orangeβ€’2y ago
Cool thanks :)
1Lucas1.apk
1Lucas1.apkβ€’2y ago
?play disfruto
Blobit - Moonlink.js
you are not on a voice channel
foreign-sapphire
foreign-sapphireβ€’2y ago
in our thread 😭
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I messed up the chat Ksksk I was doing a test @Jul 🌹 Did you manage to fix it?
foreign-sapphire
foreign-sapphireβ€’2y ago
no
1Lucas1.apk
1Lucas1.apkβ€’2y ago
If you want me to review the codes, I can take a look and fix the problem
foreign-sapphire
foreign-sapphireβ€’2y ago
does @Blobit - Moonlink.js do mp3 urls?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Yes, accept moonlink.js is integrated directly into it
Blobit - Moonlink.js
discordlogo Music.
<:Nota_Musica__Mlink:960665601574055966>β•Ίβ•ΈTitle:
<:Estrela_Mlink:960660485999587348>β•Ίβ•ΈUri:
<:emoji_21:967836966714503168>β•Ίβ•ΈAuthor:
XenoFM
<:emoji_23:967837516558393365>β•Ίβ•ΈDuration:
-2 Days, -12 Hours, -21 Minutes, -488 Seconds
Request for: aqhe
Blobit - Moonlink.js
XenoFM. is playing now [ time test result: 323ms ]
foreign-sapphire
foreign-sapphireβ€’2y ago
can u force disconnect it? like not via command
foreign-sapphire
foreign-sapphireβ€’2y ago
No description
foreign-sapphire
foreign-sapphireβ€’2y ago
like that
Blobit - Moonlink.js
as musicas acabaram
foreign-sapphire
foreign-sapphireβ€’2y ago
what
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I disconnected it
foreign-sapphire
foreign-sapphireβ€’2y ago
Blobit - Moonlink.js
discordlogo Music.
<:Nota_Musica__Mlink:960665601574055966>β•Ίβ•ΈTitle:
<:Estrela_Mlink:960660485999587348>β•Ίβ•ΈUri:
<:emoji_21:967836966714503168>β•Ίβ•ΈAuthor:
XenoFM
<:emoji_23:967837516558393365>β•Ίβ•ΈDuration:
-2 Days, -12 Hours, -21 Minutes, -488 Seconds
Request for: aqhe
Blobit - Moonlink.js
XenoFM. is playing now [ time test result: 309ms ]
foreign-sapphire
foreign-sapphireβ€’2y ago
why does yours work but not ours
1Lucas1.apk
1Lucas1.apkβ€’2y ago
It was on Discord
foreign-sapphire
foreign-sapphireβ€’2y ago
ours doesnt join back
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I went to his profile and disconnected
foreign-sapphire
foreign-sapphireβ€’2y ago
good
1Lucas1.apk
1Lucas1.apkβ€’2y ago
As I said, moonlink.js has parameters for this, but strangely it doesn't work on yours
foreign-sapphire
foreign-sapphireβ€’2y ago
no clue why
1Lucas1.apk
1Lucas1.apkβ€’2y ago
If you want I can review, I have free time until 12pm - BR
foreign-sapphire
foreign-sapphireβ€’2y ago
br
MEE6
MEE6β€’2y ago
GG @Jul 🌹, you just advanced to level 2!
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Brazil
foreign-sapphire
foreign-sapphireβ€’2y ago
ok thats 3 hrs?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
It's 8:13 am Yes, I got a problem
foreign-sapphire
foreign-sapphireβ€’2y ago
?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
It was in moonlink.js when I found it and fixed it
foreign-sapphire
foreign-sapphireβ€’2y ago
wdym our problem?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
It was very simple, and the players were still playing, but I didn't put the correct If
foreign-sapphire
foreign-sapphireβ€’2y ago
oki so when we update our package it will work? we deserve bughunter role now
1Lucas1.apk
1Lucas1.apkβ€’2y ago
It depends if the error is not external
foreign-sapphire
foreign-sapphireβ€’2y ago
1Lucas1.apk
1Lucas1.apkβ€’2y ago
As I explained to @justin The error in events And why don't you assign the values ​​before launching Collection(discord.js) or map
foreign-sapphire
foreign-sapphireβ€’2y ago
not my fault haha
1Lucas1.apk
1Lucas1.apkβ€’2y ago
After it is played there they do not receive updates on the new parameters
foreign-sapphire
foreign-sapphireβ€’2y ago
@Justin baba grill listen to big man Lucas
1Lucas1.apk
1Lucas1.apkβ€’2y ago
In my language this sounds like irony
foreign-sapphire
foreign-sapphireβ€’2y ago
it is ur a goat tho without u the package wouldn't be there so don't take offense :D :Sk
foreign-sapphire
foreign-sapphireβ€’2y ago
No description
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Like it or not, it offends
foreign-sapphire
foreign-sapphireβ€’2y ago
what was offending
1Lucas1.apk
1Lucas1.apkβ€’2y ago
I don't accept this kind of thing
foreign-sapphire
foreign-sapphireβ€’2y ago
i didnt mean it offensive? i said listen to big man Lucas
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Here you said I'm a goat
foreign-sapphire
foreign-sapphireβ€’2y ago
yeah do you know what is a goat? not the animal dum dum goat: abbreviation for Greatest Of All Time: used to refer to or describe the person who has performed better than anyone else ever
1Lucas1.apk
1Lucas1.apkβ€’2y ago
In my translation it means that it is an animal, be more specific when you say it or else I will confuse things
foreign-sapphire
foreign-sapphireβ€’2y ago
yes in here it is also an animal but we are in the metaverse in the metaverse we use online words and short forms like GOAT
Justin
JustinOPβ€’2y ago
Entire different question right now. Is it possible to lower the volume of the audio/music (whatever is playing) of the discord bot? Like setting the volume to 50% or something like that.
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Yes With
player.volume(boolean)
player.volume(boolean)
Justin
JustinOPβ€’2y ago
TypeError: player.volume is not a function ?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
You implemented it incorrectly
Justin
JustinOPβ€’2y ago
Huh, I did?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
If you don't define player it won't work
Justin
JustinOPβ€’2y ago
Should be implemented right, this is my code; https://sourceb.in/0yhUYPDBHq And yes, I defined player.
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Keyboard changed is setVolume
Justin
JustinOPβ€’2y ago
ah so it's player.setVolume(boolean)?
foreign-sapphire
foreign-sapphireβ€’2y ago
yes
Justin
JustinOPβ€’2y ago
Different question @1Lucas1.apk. Is it possible to apply filters to the music? Like making the music bass boosted or something like that?
1Lucas1.apk
1Lucas1.apkβ€’2y ago
GitHub
moonlink.js/src/@Rest/MoonlinkFilters.ts at v2 Β· 1Lucas1apk/moonlin...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. Support Server: https://discord.gg/xQq2A8vku3 - 1Lucas1...
1Lucas1.apk
1Lucas1.apkβ€’2y ago
Yes

Did you find this page helpful?