Bot don't play audiostream (shoutcast)

Hi, I'm trying to play an audio stream from a shoutcast server in my bot but Idk how to do it, this is the code Node V: v20.2.0 [email protected]
const { Client, GatewayIntentBits, ActivityType} = require('discord.js');
const { joinVoiceChannel, getVoiceConnection, createAudioPlayer, NoSubscriberBehavior, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.config = require("./config.json");

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

const resource = createAudioResource('http://radio.fenixzone.com:8000/stream/1763315/', {
inlineVolume: true
});
require('./modules/commands.js');

client.login(client.config.token)
.then(() => {
console.log("Bot started..."); //Send this message when bot is online to the console.
})
.catch((err) => console.log(`Error ${err}`));

client.on('ready', (c) => {
client.user.setActivity({
name: '¡Crucks FM!',
type: ActivityType.Listening,
url: "..."
});
});

client.on('interactionCreate', (interaction) => {
let canal = interaction.member.voice.channel;
if(interaction.commandName == 'stereo' && interaction.isChatInputCommand())
{
if (!canal) { return interaction.reply({ content: ':red_circle: Debes estar conectado a un canal de voz para usar este comando!' }) }
if (!canal.joinable) { return interaction.reply({ content: ':red_circle: No tengo permiso para entrar al canal de voz.' }) }

const connection = joinVoiceChannel({
channelId: canal.id,
guildId: canal.guild.id,
adapterCreator: canal.guild.voiceAdapterCreator,
});
player.play(resource);
connection.subscribe(player);
interaction.reply(`🟢 Conectado al canal de voz!`);
}
});
const { Client, GatewayIntentBits, ActivityType} = require('discord.js');
const { joinVoiceChannel, getVoiceConnection, createAudioPlayer, NoSubscriberBehavior, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.config = require("./config.json");

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

const resource = createAudioResource('http://radio.fenixzone.com:8000/stream/1763315/', {
inlineVolume: true
});
require('./modules/commands.js');

client.login(client.config.token)
.then(() => {
console.log("Bot started..."); //Send this message when bot is online to the console.
})
.catch((err) => console.log(`Error ${err}`));

client.on('ready', (c) => {
client.user.setActivity({
name: '¡Crucks FM!',
type: ActivityType.Listening,
url: "..."
});
});

client.on('interactionCreate', (interaction) => {
let canal = interaction.member.voice.channel;
if(interaction.commandName == 'stereo' && interaction.isChatInputCommand())
{
if (!canal) { return interaction.reply({ content: ':red_circle: Debes estar conectado a un canal de voz para usar este comando!' }) }
if (!canal.joinable) { return interaction.reply({ content: ':red_circle: No tengo permiso para entrar al canal de voz.' }) }

const connection = joinVoiceChannel({
channelId: canal.id,
guildId: canal.guild.id,
adapterCreator: canal.guild.voiceAdapterCreator,
});
player.play(resource);
connection.subscribe(player);
interaction.reply(`🟢 Conectado al canal de voz!`);
}
});
2 Replies
d.js toolkit
d.js toolkit14mo 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!
Nounejm
Nounejm14mo ago
make a https request to that link, don't put it to the resource
https.get('url', (res) => {
let resource = createAudioResource(res)
...
})
https.get('url', (res) => {
let resource = createAudioResource(res)
...
})
Want results from more Discord servers?
Add your server