Lavashark to Moonlink

Good morning,I'm having issues with the play command everything is setup correctly.
6 Replies
Fonzo
FonzoOP•7mo ago
i still need help!
case "play": {
if (!voiceChannel) {
return interaction.editReply({
content: "You need to be in a voice channel!",
ephemeral: true,
});
}

const query = interaction.options.getString("query");
if (!query || typeof query !== "string") {
return interaction.editReply({
content: "Please specify a valid song name or URL to play.",
ephemeral: true,
});
}

console.log("Query:", query); // Debugging

const player = client.manager.createPlayer({
guildId: guild.id,
voiceChannelId: voiceChannel.id,
textChannelId: interaction.channel.id,
autoPlay: true,
});

player.connect();

try {
const result = await client.manager.search(query, interaction.user);
if (!result || !result.tracks || !result.tracks.length) {
return interaction.editReply({
content: "No results found for your query.",
ephemeral: true,
});
}

player.queue.add(result.tracks[0]);
if (!player.playing) player.play();

return interaction.editReply({
content: `Added to queue: **${result.tracks[0].title}**`,
});
} catch (error) {
console.error("Error during search:", error);
return interaction.editReply({
content: "An error occurred while searching for the song.",
ephemeral: true,
});
}
}
case "play": {
if (!voiceChannel) {
return interaction.editReply({
content: "You need to be in a voice channel!",
ephemeral: true,
});
}

const query = interaction.options.getString("query");
if (!query || typeof query !== "string") {
return interaction.editReply({
content: "Please specify a valid song name or URL to play.",
ephemeral: true,
});
}

console.log("Query:", query); // Debugging

const player = client.manager.createPlayer({
guildId: guild.id,
voiceChannelId: voiceChannel.id,
textChannelId: interaction.channel.id,
autoPlay: true,
});

player.connect();

try {
const result = await client.manager.search(query, interaction.user);
if (!result || !result.tracks || !result.tracks.length) {
return interaction.editReply({
content: "No results found for your query.",
ephemeral: true,
});
}

player.queue.add(result.tracks[0]);
if (!player.playing) player.play();

return interaction.editReply({
content: `Added to queue: **${result.tracks[0].title}**`,
});
} catch (error) {
console.error("Error during search:", error);
return interaction.editReply({
content: "An error occurred while searching for the song.",
ephemeral: true,
});
}
}
1Lucas1.apk
1Lucas1.apk•7mo ago
Hello
case "play": {
if (!voiceChannel) {
return interaction.editReply({
content: "You need to be in a voice channel!",
ephemeral: true,
});
}

const query = interaction.options.getString("query");
if (!query || typeof query !== "string") {
return interaction.editReply({
content: "Please specify a valid song name or URL to play.",
ephemeral: true,
});
}

console.log("Query:", query); // Debugging

const player = client.manager.createPlayer({
guildId: guild.id,
voiceChannelId: voiceChannel.id,
textChannelId: interaction.channel.id,
autoPlay: true,
});

player.connect();

try {
const result = await client.manager.search({
query, requester: interaction.user });
if (!result || !result.tracks || !result.tracks.length) {
return interaction.editReply({
content: "No results found for your query.",
ephemeral: true,
});
}

player.queue.add(result.tracks[0]);
if (!player.playing) player.play();

return interaction.editReply({
content: `Added to queue: **${result.tracks[0].title}**`,
});
} catch (error) {
console.error("Error during search:", error);
return interaction.editReply({
content: "An error occurred while searching for the song.",
ephemeral: true,
});
}
}
case "play": {
if (!voiceChannel) {
return interaction.editReply({
content: "You need to be in a voice channel!",
ephemeral: true,
});
}

const query = interaction.options.getString("query");
if (!query || typeof query !== "string") {
return interaction.editReply({
content: "Please specify a valid song name or URL to play.",
ephemeral: true,
});
}

console.log("Query:", query); // Debugging

const player = client.manager.createPlayer({
guildId: guild.id,
voiceChannelId: voiceChannel.id,
textChannelId: interaction.channel.id,
autoPlay: true,
});

player.connect();

try {
const result = await client.manager.search({
query, requester: interaction.user });
if (!result || !result.tracks || !result.tracks.length) {
return interaction.editReply({
content: "No results found for your query.",
ephemeral: true,
});
}

player.queue.add(result.tracks[0]);
if (!player.playing) player.play();

return interaction.editReply({
content: `Added to queue: **${result.tracks[0].title}**`,
});
} catch (error) {
console.error("Error during search:", error);
return interaction.editReply({
content: "An error occurred while searching for the song.",
ephemeral: true,
});
}
}
Fonzo
FonzoOP•7mo ago
thank you very much, I fixed my own problem but now the bot won't connect to the voice channel and play the song.
1Lucas1.apk
1Lucas1.apk•7mo ago
In the constructor It has the sendPayload Put JSON.parse(payload) This is how it should work
Fonzo
FonzoOP•7mo ago
@1Lucas1.apk in my play command or when i initialize the bot oh okay i see @1Lucas1.apk TypeError: Cannot read properties of undefined (reading 'artworkUrl') im trying to retrieve the current song artwork how do i add spotify to the manager cause wtf
ComicallyBad
ComicallyBad•7mo ago
track.thumbnail For spotify, I believe you just need the Lavasrc plugin application.yml
lavalink:
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.3.0"
repository: "https://maven.lavalink.dev/releases"
snapshot: false
- dependency: "dev.lavalink.youtube:youtube-plugin:1.12.0"
repository: "https://maven.lavalink.dev/releases"
lavalink:
plugins:
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.3.0"
repository: "https://maven.lavalink.dev/releases"
snapshot: false
- dependency: "dev.lavalink.youtube:youtube-plugin:1.12.0"
repository: "https://maven.lavalink.dev/releases"

Did you find this page helpful?