discordjs / discordjs/voice-examples

@discordjs/voice example is incorrect

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
bug need repro
Dominant language
No language data
Stars
39
Forks
13
PR merge metrics
No merged PRs in 30d

Description

### Which package is this bug report for?

voice

### Issue description

See: https://github.com/discordjs/voice-examples/blob/266d250d34abf352b320be1781b6f39146eefcb3/radio-bot/src/bot.ts#L105

ISSUE: Bot will never begin playing audio because the "player" object will never emit 'stateChange'

PERCEIVED CAUSE: A state change is not being emitted until "player.play()" is called, which will emit the stateChange event that performs "attachRecorder()".

In the example, the following code is as follows:
```
const connection = await connectToChannel(channel);
connection.subscribe(player);
await message.reply('Playing now!');
```

Although a subscription is added, that in itself is not enough to emit a state change or cause the player to begin playing. In the example, following connection.subscribe(player), a new line with "player.play()" should be added.

### Code sample

_No response_

### Package version

v13.7

### Node.js version

16.12

### Operating system

Windows

### Priority this issue should have

Medium (should be fixed soon)

### Which partials do you have configured?

Not applicable (subpackage bug)

### Which gateway intents are you subscribing to?

Not applicable (subpackage bug)

### I have tested this issue on a development release

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at radio-bot/src/bot.ts around line 105 and review the sequence after connection.subscribe(player). Run the radio-bot example to confirm that the bot begins playing audio and that the recorder setup is reached when playback starts.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
audio-video-rtc
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.