Nonsen
MIA🎶 Moonlink.js - Imagine a Music Application
•Created by Nonsen on 5/6/2025 in #help
TypeError: Cannot read properties of undefined (reading 'encoded') on skip function
execute: async ({ args, context }) => {
const { position } = args;
const { message, discordClient } = context;
const guildId = message.guild?.id;
if (!guildId) {
return "This command can only be used inside a server.";
}
const player = discordClient.manager.players.get(guildId);
if (!player) {
return "No player is currently active in this server.";
}
if (!player.queue.size) {
return "There are no more songs in the queue.";
}
try {
const pos = (!position || position < 1) ? 1 : position;
if (pos > player.queue.size) {
return `Invalid position. The queue only has ${player.queue.size} song(s).`;
}
const skippedTrack = player.current;
player.skip(pos);
if (pos === 1) {
return `Skipped **${skippedTrack?.title || "Unknown Track"}**!`;
} else {
return `Skipped ahead to song #${pos} in the queue!`;
}
} catch (error) {
console.error("[skip tool] Error skipping track:", error);
return "Oops! Something went wrong trying to skip the track.";
}
}
};
execute: async ({ args, context }) => {
const { position } = args;
const { message, discordClient } = context;
const guildId = message.guild?.id;
if (!guildId) {
return "This command can only be used inside a server.";
}
const player = discordClient.manager.players.get(guildId);
if (!player) {
return "No player is currently active in this server.";
}
if (!player.queue.size) {
return "There are no more songs in the queue.";
}
try {
const pos = (!position || position < 1) ? 1 : position;
if (pos > player.queue.size) {
return `Invalid position. The queue only has ${player.queue.size} song(s).`;
}
const skippedTrack = player.current;
player.skip(pos);
if (pos === 1) {
return `Skipped **${skippedTrack?.title || "Unknown Track"}**!`;
} else {
return `Skipped ahead to song #${pos} in the queue!`;
}
} catch (error) {
console.error("[skip tool] Error skipping track:", error);
return "Oops! Something went wrong trying to skip the track.";
}
}
};
TypeError: Cannot read properties of undefined (reading 'encoded')
at Player.skip (/app/node_modules/moonlink.js/dist/src/entities/Player.js:268:39)
at Object.execute (/app/utils/music/tools/skip.js:48:20)
at /app/utils/music/LoadTools.js:30:25
at MusicHandler (/app/utils/music/musicHandler.js:154:50)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: Cannot read properties of undefined (reading 'encoded')
at Player.skip (/app/node_modules/moonlink.js/dist/src/entities/Player.js:268:39)
at Object.execute (/app/utils/music/tools/skip.js:48:20)
at /app/utils/music/LoadTools.js:30:25
at MusicHandler (/app/utils/music/musicHandler.js:154:50)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
48 replies