-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
Description
Which package is this bug report for?
voice
Issue description
When i susbcribe to the receiver, and add an event listener to the "finish" event of the opusStream, the bot crashes with the follow:
node:events:491
throw er; // Unhandled 'error' event
^
Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF
at new NodeError (node:internal/errors:387:5)
at readableAddChunk (node:internal/streams/readable:277:30)
at AudioReceiveStream.Readable.push (node:internal/streams/readable:228:10)
at AudioReceiveStream.push (file:///app/node_modules/@discordjs/voice/dist/index.mjs:1102:18)
at VoiceReceiver.onUdpMessage (file:///app/node_modules/@discordjs/voice/dist/index.mjs:1267:16)
at VoiceUDPSocket.emit (node:events:513:28)
at VoiceUDPSocket.onMessage (file:///app/node_modules/@discordjs/voice/dist/index.mjs:265:10)
at Socket.<anonymous> (file:///app/node_modules/@discordjs/voice/dist/index.mjs:247:48)
at Socket.emit (node:events:513:28)
at UDP.onMessage [as onmessage] (node:dgram:922:8)
Emitted 'error' event on AudioReceiveStream instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_STREAM_PUSH_AFTER_EOF'
}
Code sample
import { token } from "./config";
import { Client, GatewayIntentBits } from "discord.js";
import {
EndBehaviorType,
getVoiceConnection,
joinVoiceChannel,
VoiceConnectionStatus
} from "@discordjs/voice";
export const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates
]
});
bot.on("messageCreate", (msg) => {
const { guild, member } = msg;
if(!guild || !member?.voice.channelId)
return;
const channelId = member.voice.channelId;
if(msg.content !== "?join")
return;
let voiceConnection = getVoiceConnection(guild.id);
if(voiceConnection)
return;
voiceConnection = joinVoiceChannel({
channelId,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: false
});
if(!voiceConnection)
return;
voiceConnection.once(VoiceConnectionStatus.Disconnected, () => voiceConnection?.destroy());
const { receiver } = voiceConnection;
receiver.speaking.on("start", async (userId) => {
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 100
}
});
opusStream.on("finish", () => console.log("End"));
});
});
bot.once("ready", () => console.log("Bot Ready..."));
bot.login(token);Package version
@discordjs/[email protected]
Node.js version
v16.17.1
Operating system
Ubuntu 20.04
Priority this issue should have
Low (slightly annoying)
Which partials do you have configured?
Not applicable (subpackage bug)
Which gateway intents are you subscribing to?
Guilds, GuildVoiceStates, GuildMessages, MessageContent
I have tested this issue on a development release
No response