Won't play any audio

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
selfDeaf: false,
});

const player = createAudioPlayer({
behaviors: { noSubscriber: NoSubscriberBehavior.Pause },
}).on("error", (error) => {
connection.disconnect();
throw error;
});

console.log("inited");
connection
.on(VoiceConnectionStatus.Ready, () => {
console.log("ready");

connection.subscribe(player);
console.log("subscribed");
player.play(
createAudioResource(
createReadStream(
path.resolve(
path.dirname(url.fileURLToPath(import.meta.url)),
"filePath.ogg",
),
),
{ inputType: StreamType.OggOpus },
),
);
console.log("playing");
// player.on(AudioPlayerStatus.Idle, connection.disconnect);
})
.on(VoiceConnectionStatus.Disconnected, async () => {
console.log("disconnect?");
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch {
console.log("disconnect");
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
player.stop();
}
})
.on("error", (error) => {
connection.disconnect();
throw error;
});
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
selfDeaf: false,
});

const player = createAudioPlayer({
behaviors: { noSubscriber: NoSubscriberBehavior.Pause },
}).on("error", (error) => {
connection.disconnect();
throw error;
});

console.log("inited");
connection
.on(VoiceConnectionStatus.Ready, () => {
console.log("ready");

connection.subscribe(player);
console.log("subscribed");
player.play(
createAudioResource(
createReadStream(
path.resolve(
path.dirname(url.fileURLToPath(import.meta.url)),
"filePath.ogg",
),
),
{ inputType: StreamType.OggOpus },
),
);
console.log("playing");
// player.on(AudioPlayerStatus.Idle, connection.disconnect);
})
.on(VoiceConnectionStatus.Disconnected, async () => {
console.log("disconnect?");
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch {
console.log("disconnect");
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
player.stop();
}
})
.on("error", (error) => {
connection.disconnect();
throw error;
});
Console output:
inited
[VOICE] received voice state update: {/*...*/}
[VOICE] received voice server: {"t":"VOICE_SERVER_UPDATE","s":7,"op":0,"d":{"token":"removed","guild_id":"removed","endpoint":"us-central5335.discord.media:443"}}
ready
subscribed
playing
inited
[VOICE] received voice state update: {/*...*/}
[VOICE] received voice server: {"t":"VOICE_SERVER_UPDATE","s":7,"op":0,"d":{"token":"removed","guild_id":"removed","endpoint":"us-central5335.discord.media:443"}}
ready
subscribed
playing
the bot joins the vc, but nothing happens after that
9 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
cobalt
cobaltOP3y ago
works if it's not an .ogg ig
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
cobalt
cobaltOP3y ago
wdym
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
cobalt
cobaltOP3y ago
it should be an oggopus tho bc iḿ passing a ogg right?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
cobalt
cobaltOP3y ago
oh well i can just use wav, its actually easier for me that way
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server