let tracks = req.data.tracks.map((data) => new index_1.Track(data, requester));

I have 2 problems 1. My bot is connected to Lavalink but don't log in console like
[0] "HStudio - BKK" was connected.
[0] "HStudio - BKK" was connected.
2. When I search it error log in console
D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\core\Manager.js:51
let tracks = req.data.tracks.map((data) => new index_1.Track(data, requester));
^

TypeError: Cannot read properties of null (reading 'tracks')
at D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\core\Manager.js:51:35
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v22.2.0
D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\core\Manager.js:51
let tracks = req.data.tracks.map((data) => new index_1.Track(data, requester));
^

TypeError: Cannot read properties of null (reading 'tracks')
at D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\core\Manager.js:51:35
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v22.2.0
Search Code
let res = await client.moon.search({
query,
source: "spsearch",
requester: interaction.user.id
});
let res = await client.moon.search({
query,
source: "spsearch",
requester: interaction.user.id
});
Full Code: https://github.com/HStudioDiscordBot/HStudioSource/tree/Bump-moonlink.js-from-3.6.64-to-4.0.1
GitHub
GitHub - HStudioDiscordBot/HStudioSource at Bump-moonlink.js-from-3...
HStudio Discord Music Bot Source Code. Contribute to HStudioDiscordBot/HStudioSource development by creating an account on GitHub.
13 Replies
HewkawAr
HewkawArOP4mo ago
Forgot to mention that I use moonlink.js version 4.0.1
1Lucas1.apk
1Lucas1.apk4mo ago
My lavalink doesn't even work to test kakakkaa
HewkawAr
HewkawArOP4mo ago
ahh why i can't search? If i put song url it can play but when i put song query it send undefined to lavalink but it should send spsearch:you belong with me
let res = await client.moon.search({
query,
source: "spsearch",
requester: interaction.user.id
});
let res = await client.moon.search({
query,
source: "spsearch",
requester: interaction.user.id
});
2024-07-25T21:17:32.973+07:00 INFO 20860 --- [ XNIO-1 task-2] l.server.player.AudioLoaderRestHandler : Got request to load for identifier "undefined:you belong with me"
2024-07-25T21:17:32.973+07:00 INFO 20860 --- [ XNIO-1 task-2] l.server.player.AudioLoaderRestHandler : Got request to load for identifier "undefined:you belong with me"
MEE6
MEE64mo ago
GG @HewkawAr, you just advanced to level 2!
1Lucas1.apk
1Lucas1.apk4mo ago
I will fix this on github @HewkawAr npm uninstall moonlink.js
1Lucas1.apk
1Lucas1.apk4mo ago
GitHub
GitHub - Ecliptia/moonlink.js: MoonLink.js is a simple package for ...
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. - GitHub - Ecliptia/moonlink.js: MoonLink.js is a simpl...
1Lucas1.apk
1Lucas1.apk4mo ago
It worked?
HewkawAr
HewkawArOP4mo ago
Yeah it work but i have more problem how to destroy player?
1Lucas1.apk
1Lucas1.apk4mo ago
player.destroy()
HewkawAr
HewkawArOP4mo ago
normally i use player.destroy() but now i use but it crash
undefined:1


SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:4306:19)
at successSteps (node:internal/deps/undici/undici:4288:27)
at consumeBody (node:internal/deps/undici/undici:4294:9)
at _Response.json (node:internal/deps/undici/undici:4239:18)
at D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\Utils.js:12:28
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Rest.destroy (D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\entities\Rest.js:46:23)
at async PlayerManager.delete (D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\management\PlayerManager.js:43:9)

Node.js v22.2.0
undefined:1


SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at parseJSONFromBytes (node:internal/deps/undici/undici:4306:19)
at successSteps (node:internal/deps/undici/undici:4288:27)
at consumeBody (node:internal/deps/undici/undici:4294:9)
at _Response.json (node:internal/deps/undici/undici:4239:18)
at D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\Utils.js:12:28
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Rest.destroy (D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\entities\Rest.js:46:23)
at async PlayerManager.delete (D:\.Projects\HewkawDiscordBotProject\HStudio\node_modules\moonlink.js\dist\src\management\PlayerManager.js:43:9)

Node.js v22.2.0
const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("leave")
.setDescription("Leave from Voice Channel")
.setDescriptionLocalizations({
th: "ออกจากห้องเสียง"
}),

/**
*
* @param {import("discord.js").CommandInteraction} interaction
* @param {import("discord.js").Client} client
* @param {import("../../class/Locale")} locale
*/
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.botNotInVoiceChannel"))
]
});
}

if (player.destroy()) {
interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.leaved"))
]
});
} else {
interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.fail"))
]
});
}
}
};
const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("leave")
.setDescription("Leave from Voice Channel")
.setDescriptionLocalizations({
th: "ออกจากห้องเสียง"
}),

/**
*
* @param {import("discord.js").CommandInteraction} interaction
* @param {import("discord.js").Client} client
* @param {import("../../class/Locale")} locale
*/
async execute(interaction, client, locale) {
if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] });

let player = client.moon.createPlayer({
guildId: interaction.guild.id,
voiceChannelId: interaction.member.voice.channel.id,
textChannelId: interaction.channel.id,
autoLeave: true,
autoPlay: true
});

if (!player.connected) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.botNotInVoiceChannel"))
]
});
}

if (player.destroy()) {
interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.leaved"))
]
});
} else {
interaction.reply({
embeds: [
new EmbedBuilder()
.setColor(Colors.Red)
.setDescription(locale.getLocaleString("command.leave.fail"))
]
});
}
}
};
1Lucas1.apk
1Lucas1.apk4mo ago
my mistake in fetch it has res.json() asking for a parse on something that returns nothing Done, uninstall the package and reinstall using github It is
HewkawAr
HewkawArOP4mo ago
oh it's looking good if i found more problem i will tell you
1Lucas1.apk
1Lucas1.apk4mo ago
have a great day :)
Want results from more Discord servers?
Add your server