How to stream icecast to Voice Channel with discord.js?

165 Views Asked by At

I have a radio station Icecast stream I wish to stream into a Discord Voice Channel with a discord.js bot. It does not have Mute or Deafen icons, so that's set correct, but when I join I do not hear any audio.

The logs show it should be playing: The audio player has started playing!

<ref *1> AudioPlayer { _events: [Object: null prototype] { playing: [Function (anonymous)] }, _eventsCount: 1, _maxListeners: undefined, _state: { status: 'playing', missedFrames: 0, playbackDuration: 100, resource: AudioResource { playStream: [OggDemuxer], edges: [Array], metadata: null, volume: 1, encoder: undefined, audioPlayer: [Circular *1], playbackDuration: 0, started: true, silencePaddingFrames: 5, silenceRemaining: -1, seek: 0 },

It has the intents:

const client = new Client({
  intents: [
    GatewayIntentBits.DirectMessages,
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildBans,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildVoiceStates,
    GatewayIntentBits.MessageContent,
  ],
  partials: [Partials.Channel],
});

Code for playing:

// Bot joins voice channel
const player = createAudioPlayer();
const vcid = "VOICECHANNELID";
const guildid = "GUILDID";

client.on("ready",() => {
  const connection = VoiceDiscord.joinVoiceChannel({
    channelId: vcid,
    guildId: guildid,
    adapterCreator: client.guilds.cache.find(guild => guild.id == guildid).voiceAdapterCreator,
    selfDeaf: false,
    selfMute: false
  })
  const resource = createAudioResource(icecastStream, { inputType: StreamType.Arbitrary });
  resource.volume = 1;
  resource.seek = 0;
  player.play(resource);
  connection.subscribe(player);
});

Cheers!

0

There are 0 best solutions below