Måneskin
Måneskin
DIAdiscord.js - Imagine an app
Created by Måneskin on 9/28/2023 in #djs-voice
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!`);
}
});
4 replies