Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@discordjs/voice not working with Bun #10296

Open
SkyLissh opened this issue May 22, 2024 · 1 comment
Open

@discordjs/voice not working with Bun #10296

SkyLissh opened this issue May 22, 2024 · 1 comment

Comments

@SkyLissh
Copy link

SkyLissh commented May 22, 2024

Which package is this bug report for?

voice

Issue description

Jus try a basic example of creating a voice connection with joinVoiceChannel and get the connection with getVoiceConnection, and play any audio file like and .mp3, after that the player will enter in Buffering state and never will change to Playing. This exact code was tested on Node v20.13.1 and it works without any problem.

Another thing to point out, is that I also tested an .ogg file, with the createStream function, in that case the player state changes, but the audio doesn't play.

Code sample

const channel = interaction.channel;
    if (!channel || !channel.isVoiceBased()) return;

    const connectionChannel = joinVoiceChannel({
      channelId: channel.id,
      guildId: (channel as VoiceBasedChannel).guild.id,
      adapterCreator: (channel as VoiceBasedChannel).guild.voiceAdapterCreator,
    });

    connectionChannel.on(VoiceConnectionStatus.Signalling, () => {
      console.log("Connecting...");
    });
    connectionChannel.on(VoiceConnectionStatus.Ready, () => {
      console.log("Player ready");
    }); 

    const speechFile = path.resolve(process.cwd(), "speech.mp3");

    const connection = getVoiceConnection(interaction.guildId!);
    if (!connection) return;

    const resource = createAudioResource(speechFile, {
      metadata: { title: "test" },
    });
    const player = createAudioPlayer();

    player.on(AudioPlayerStatus.Idle, () => {
      console.log("Idle");
    });
    player.on(AudioPlayerStatus.Buffering, () => {
      console.log("Buffering");
    });
    player.on(AudioPlayerStatus.Playing, () => {
      console.log("Playing");
    });
    player.on("stateChange", (oldState, newState) => {
      console.log(
        `Audio player transitioned from ${oldState.status} to ${newState.status}`
      );
    });
    player.on("error", (error) => {
      console.error("Error:", error.message);
    });

    connection.subscribe(player);
    player.play(resource);

Versions

  • discordjs v14.5.2
  • Bun v1.1.8
  • Typescript v5.0.0
  • WSL 2 Fedora 38

@discordjs/voice Report

Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0.1
- libopus: yes

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildVoiceStates, GuildMessages, MessageContent

I have tested this issue on a development release

No response

@iCrawl
Copy link
Member

iCrawl commented May 22, 2024

If it works in node but not in bun, its a bug in bun and should likely be reported on their end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants