Problem with play external URL

TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received undefined
at new NodeError (node:internal/errors:393:5)
at duplexify (node:internal/streams/duplexify:199:9)
at Duplex.from (node:internal/streams/duplex:146:10)
at pipelineImpl (node:internal/streams/pipeline:259:22)
at pipeline (node:internal/streams/pipeline:151:10)
at new AudioResource (Manager-music-Dev-Rework\node_modules\@discordjs\voice\dist\index.js:2337:77)
at createAudioResource (Manager-music-Dev-Rework\node_modules\@discordjs\voice\dist\index.js:2431:10)
at playURL (CManager-music-Dev-Rework\cmd\play.js:104:23)
at runtime (Manager-music-Dev-Rework\cmd\play.js:135:5)
at Manager-music-Dev-Rework\cmd\list.js:48:10 {
code: 'ERR_INVALID_ARG_TYPE'
}
[ACTION] User > klubuntu in [:computer: Klubuntu Community]
[BOT] Command /play-online url:http://www.emsoft.ct8.pl/inne/time.m3u?id=2030
[DEBUG] Detected URL: http://ic1.smcdn.pl/2030-1.mp3
TypeError [ERR_INVALID_ARG_TYPE]: The "body" argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received undefined
at new NodeError (node:internal/errors:393:5)
at duplexify (node:internal/streams/duplexify:199:9)
at Duplex.from (node:internal/streams/duplex:146:10)
at pipelineImpl (node:internal/streams/pipeline:259:22)
at pipeline (node:internal/streams/pipeline:151:10)
at new AudioResource (Manager-music-Dev-Rework\node_modules\@discordjs\voice\dist\index.js:2337:77)
at createAudioResource (Manager-music-Dev-Rework\node_modules\@discordjs\voice\dist\index.js:2431:10)
at playURL (CManager-music-Dev-Rework\cmd\play.js:104:23)
at runtime (Manager-music-Dev-Rework\cmd\play.js:135:5)
at Manager-music-Dev-Rework\cmd\list.js:48:10 {
code: 'ERR_INVALID_ARG_TYPE'
}
[ACTION] User > klubuntu in [:computer: Klubuntu Community]
[BOT] Command /play-online url:http://www.emsoft.ct8.pl/inne/time.m3u?id=2030
[DEBUG] Detected URL: http://ic1.smcdn.pl/2030-1.mp3
Play only work if use detected url without playlist, add await/async no fix problem
4 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Klubuntu
KlubuntuOP17mo ago
Only one function
async function playURL(interaction){
const config = interaction.locale_config
const player = interaction.legacyPlayer
const channel = interaction.member.voice.channel;
if (!channel) {
msg_user_not_voicechannel = "❌ " + config.messages.user_not_connected;
console.log(msg_user_not_voicechannel);
interaction.reply(msg_user_not_voicechannel);
userJoined = false;
return;
}
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: interaction.member.voice.channel.guild.id,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

let url = interaction.options.getString("url");
newUrl = detectLink(url);
try{
await player.play(createAudioResource(detectLink(url)), { type: 'unknown' });
connection.subscribe(player);
interaction.legacyPlayer.test = player
interaction.track = {
raw: {},
__metadata: {
source: "stream URL",
uploadedAt: ""
},
title: "Stream URL",
duration: `${getEmoji("rec")} LIVE`,
url: "https://manager-discord.netlify.app",
thumbnail: "",
}
interaction.reply(`${config.messages.play[1].playing} <${url}>`);
interaction.playEvent(interaction);
}
catch(e){
console.error(e);
}
}
async function playURL(interaction){
const config = interaction.locale_config
const player = interaction.legacyPlayer
const channel = interaction.member.voice.channel;
if (!channel) {
msg_user_not_voicechannel = "❌ " + config.messages.user_not_connected;
console.log(msg_user_not_voicechannel);
interaction.reply(msg_user_not_voicechannel);
userJoined = false;
return;
}
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: interaction.member.voice.channel.guild.id,
adapterCreator: interaction.member.voice.channel.guild.voiceAdapterCreator,
});

let url = interaction.options.getString("url");
newUrl = detectLink(url);
try{
await player.play(createAudioResource(detectLink(url)), { type: 'unknown' });
connection.subscribe(player);
interaction.legacyPlayer.test = player
interaction.track = {
raw: {},
__metadata: {
source: "stream URL",
uploadedAt: ""
},
title: "Stream URL",
duration: `${getEmoji("rec")} LIVE`,
url: "https://manager-discord.netlify.app",
thumbnail: "",
}
interaction.reply(`${config.messages.play[1].playing} <${url}>`);
interaction.playEvent(interaction);
}
catch(e){
console.error(e);
}
}
config is external yml file parsed to dict Function for detect MP3 adress, from m3u or pls link, else return default adress
Klubuntu
KlubuntuOP17mo ago
My code for this function
Klubuntu
KlubuntuOP17mo ago
They should return a link, at least that's what console.log shows then how do I return, if I can not return by return, and I do not want to use again promise, async and await That is, the next step would be to add to detectlink, then ? that is, I should give the result of getLink in then ? declare using in playURL from function detectLink use in Then ? Should I add to my playURL function , then for for detectLink, or add something else ?
Want results from more Discord servers?
Add your server