Error when searching for a song

Hey there! Im getting this very weird error when trying to play a simple song, I copied the example in the docs so far, only adjusted it a bit for my bots structure
No description
30 Replies
Aertic
AerticOP•12mo ago
const song = interaction.options.get('song').value;

const vc = await interaction.member.voice.channel;
if (!vc) {
await errorHandler({
interaction: interaction,
errorType: 'voiceChannelRequired',
commandName: module.exports.name,
});
return;
}

let player = polaris.moon.players.create({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoPlay: true,
});
if (!player.connected) {
player.connect({
setDeaf: true,
setMute: false,
});
}

let res = await polaris.moon.search({
song,
source: 'youtube',
requester: interaction.user.id,
});

if (res.loadType === 'loadfailed') {
return interaction.editReply({
content: `:x: Load failed - the system is not cooperating.`,
});
} else if (res.loadType === 'empty') {
return interaction.editReply({
content: `:x: No matches found!`,
});
}

if (res.loadType === 'playlist') {
interaction.editReply({
content: `${res.playlistInfo.name} This playlist has been added to the waiting list, spreading joy`,
});
for (const track of res.tracks) {
player.queue.add(track);
}
} else {
player.queue.add(res.tracks[0]);
interaction.editReply({
content: `${res.tracks[0].title} was added to the waiting list`,
});
}
}
const song = interaction.options.get('song').value;

const vc = await interaction.member.voice.channel;
if (!vc) {
await errorHandler({
interaction: interaction,
errorType: 'voiceChannelRequired',
commandName: module.exports.name,
});
return;
}

let player = polaris.moon.players.create({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel.id,
textChannel: interaction.channel.id,
autoPlay: true,
});
if (!player.connected) {
player.connect({
setDeaf: true,
setMute: false,
});
}

let res = await polaris.moon.search({
song,
source: 'youtube',
requester: interaction.user.id,
});

if (res.loadType === 'loadfailed') {
return interaction.editReply({
content: `:x: Load failed - the system is not cooperating.`,
});
} else if (res.loadType === 'empty') {
return interaction.editReply({
content: `:x: No matches found!`,
});
}

if (res.loadType === 'playlist') {
interaction.editReply({
content: `${res.playlistInfo.name} This playlist has been added to the waiting list, spreading joy`,
});
for (const track of res.tracks) {
player.queue.add(track);
}
} else {
player.queue.add(res.tracks[0]);
interaction.editReply({
content: `${res.tracks[0].title} was added to the waiting list`,
});
}
}
my code index.js
polaris.moon = new MoonlinkManager(
[
{
host: "0.0.0.0",
port: 2333,
secure: false,
password: "youshallnotpass"
}
],
{
/* Options */
},
(guild, sPayload) => {
// Sending payload information to the server
polaris.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);

// Event: Node created
polaris.moon.on("nodeCreate", node => {
console.log(`${node.host} was connected, and the magic is in the air`);
});

// Event: Track start
polaris.moon.on("trackStart", async (player, track) => {
// Sending a message when the track starts playing
polaris.channels.cache
.get(player.textChannel)
.send(`${track.title} is playing now, bringing holiday joy`);
});

// Event: Track end
polaris.moon.on("trackEnd", async (player, track) => {
// Sending a message when the track finishes playing
polaris.channels.cache
.get(player.textChannel)
.send(`The track is over, but the magic continues`);
});

// Event: Ready
polaris.on("ready", () => {
// Initializing the Moonlink.js package with the polaris's user ID
polaris.moon.init(polaris.user.id);
});

// Event: Raw data
polaris.on("raw", data => {
// Updating the Moonlink.js package with the necessary data
polaris.moon.packetUpdate(data);
});
polaris.moon = new MoonlinkManager(
[
{
host: "0.0.0.0",
port: 2333,
secure: false,
password: "youshallnotpass"
}
],
{
/* Options */
},
(guild, sPayload) => {
// Sending payload information to the server
polaris.guilds.cache.get(guild).shard.send(JSON.parse(sPayload));
}
);

// Event: Node created
polaris.moon.on("nodeCreate", node => {
console.log(`${node.host} was connected, and the magic is in the air`);
});

// Event: Track start
polaris.moon.on("trackStart", async (player, track) => {
// Sending a message when the track starts playing
polaris.channels.cache
.get(player.textChannel)
.send(`${track.title} is playing now, bringing holiday joy`);
});

// Event: Track end
polaris.moon.on("trackEnd", async (player, track) => {
// Sending a message when the track finishes playing
polaris.channels.cache
.get(player.textChannel)
.send(`The track is over, but the magic continues`);
});

// Event: Ready
polaris.on("ready", () => {
// Initializing the Moonlink.js package with the polaris's user ID
polaris.moon.init(polaris.user.id);
});

// Event: Raw data
polaris.on("raw", data => {
// Updating the Moonlink.js package with the necessary data
polaris.moon.packetUpdate(data);
});
1Lucas1.apk
1Lucas1.apk•12mo ago
Hello, thank you very much for reporting the bug, it seems that a property is not working as expected, I will fix it and publish a new version correcting this error I apologize for the delay in responding, I'm not feeling very well these days.
Aertic
AerticOP•12mo ago
Okay, no problem, I actually fixed some of this, by doing this
Aertic
AerticOP•12mo ago
No description
Aertic
AerticOP•12mo ago
So that solves my first issue but not the .setPosition one If you dont mind I would suggest an update to the docs, and maybe to the function itsself, as it says the 'search' parameter but in reality you pass the query parameter
Aertic
AerticOP•12mo ago
Thanks for updating the lib, I tested it and it works now yay! however when the song finishes, I get this error? Not sure if its an issue on my end but doesnt look like it
No description
MEE6
MEE6•12mo ago
GG @Aertic, you just advanced to level 1!
Aertic
AerticOP•12mo ago
nvm it seems to back to the payload error for some reason
1Lucas1.apk
1Lucas1.apk•12mo ago
Could you send me the error?
Aertic
AerticOP•12mo ago
Same one Payload position I got this when my song ended, didnt get to play a second one
1Lucas1.apk
1Lucas1.apk•12mo ago
I published a new version, see if the error still exists?
Aertic
AerticOP•12mo ago
hey, sorry for the delay, tried to play a song got this
No description
1Lucas1.apk
1Lucas1.apk•12mo ago
Could you copy and paste the error here in the chat? I need the characters to fix them in Parse .
Aertic
AerticOP•12mo ago
{"op":"playerUpdate","state":{"time":1705336897068,"position":0,"connected":true,"ping":0},"guildId":"1131195718896455841"}�{{" here should be sufficient
1Lucas1.apk
1Lucas1.apk•12mo ago
Yes, thank you I will fix it
Aertic
AerticOP•12mo ago
thanks
1Lucas1.apk
1Lucas1.apk•12mo ago
@Aertic Could you do the test to see if it's corrected now? Because I did the analysis on my end and it worked, but the code sometimes gives false alarms on my end
Aertic
AerticOP•12mo ago
Ok, il test it later today Works thank you so much would you mind telling how to pause music or loop it and stuff?
MEE6
MEE6•12mo ago
GG @Aertic, you just advanced to level 2!
1Lucas1.apk
1Lucas1.apk•12mo ago
The pause is
player.pause()
player.pause()
For loop
player.setLoop(<value>)
player.setLoop(<value>)
If the value is 1 it will repeat the track that is playing, if it is 2 it will repeat the queue @Aertic I hope I helped :), if you have any other questions, just ask 🙂
Aertic
AerticOP•12mo ago
okay thanks are all these actions written somewhere? and how can I fetch the player from a different file? Lets say ive got a pause command inside a different file than the play command, and need to pause
1Lucas1.apk
1Lucas1.apk•12mo ago
The player can be obtained using the players class For example
<moon>.players.get(guildId)
<moon>.players.get(guildId)
This way you get a guild player
polaris.moon.players.get(interaction.guild.id)
polaris.moon.players.get(interaction.guild.id)
Then you can assign this value to let player And use the functions I'm going to make some wikis on the documentation, because it's very raw
Aertic
AerticOP•12mo ago
Ok, thanks And is there a dynamic autoplay toggle? So i dont need to define it on player creation
1Lucas1.apk
1Lucas1.apk•12mo ago
It has setAutoPlay in the player
player.setAutoPlay(<boolean>)
player.setAutoPlay(<boolean>)
Aertic
AerticOP•12mo ago
thanks just a quick question, can I somehow add support for more streaming platforms? or are all of them included by default
1Lucas1.apk
1Lucas1.apk•12mo ago
Hello, this is by default from lavalink, it only supports SoundCloud, YouTube Music, YouTube, and other types of streams such as http For platforms like Spotify, Deezer, Apple Music, and other external platforms, a lavalink collaborator has a plugin called lavaSrc Setting it up is very simple
1Lucas1.apk
1Lucas1.apk•12mo ago
No description
1Lucas1.apk
1Lucas1.apk•12mo ago
In application.yml You add the plugin That lavalink will automatically download
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.0.0"
- dependency: "dev.schlaubi.lyrics:lavalink:2.2.1"
repository: "https://maven.lavalink.dev/releases"
snapshot: false
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.0.0"
- dependency: "dev.schlaubi.lyrics:lavalink:2.2.1"
repository: "https://maven.lavalink.dev/releases"
snapshot: false
Configure the plugin
plugins:
lavasrc:
providers:
- "ytsearch:\"%ISRC%\""
- "ytsearch:%QUERY%"
sources:
spotify: true
applemusic: false
deezer: false
yandexmusic: false
flowerytts: false
youtube: true
spotify:
clientId: "c6f6b3a0eef44133b9f17903135a6184"
clientSecret: "139fcd0326944181a16c8345ec278ea5"
countryCode: "US"
playlistLoadLimit: 6
albumLoadLimit: 6
applemusic:
countryCode: "US"
mediaAPIToken: "..."
playlistLoadLimit: 6
albumLoadLimit: 6
deezer:
masterDecryptionKey: "your master decryption key"
yandexmusic:
accessToken: "your access token"
flowerytts:
voice: "default voice"
translate: false
silence: 0
speed: 1.0
audioFormat: "mp3"
lyrics:
countryCode: de
plugins:
lavasrc:
providers:
- "ytsearch:\"%ISRC%\""
- "ytsearch:%QUERY%"
sources:
spotify: true
applemusic: false
deezer: false
yandexmusic: false
flowerytts: false
youtube: true
spotify:
clientId: "c6f6b3a0eef44133b9f17903135a6184"
clientSecret: "139fcd0326944181a16c8345ec278ea5"
countryCode: "US"
playlistLoadLimit: 6
albumLoadLimit: 6
applemusic:
countryCode: "US"
mediaAPIToken: "..."
playlistLoadLimit: 6
albumLoadLimit: 6
deezer:
masterDecryptionKey: "your master decryption key"
yandexmusic:
accessToken: "your access token"
flowerytts:
voice: "default voice"
translate: false
silence: 0
speed: 1.0
audioFormat: "mp3"
lyrics:
countryCode: de
By filling in the information And putting true in the ones you want There's my clientId and clientSecret 🙂 Then it looks like this
Aertic
AerticOP•12mo ago
okay, thank you so much :D
Want results from more Discord servers?
Add your server