The bot says it's playing the audio but I can't hear anything on discord.

ts

import {
createAudioPlayer,
createAudioResource,
joinVoiceChannel,
NoSubscriberBehavior,
AudioPlayerStatus,
VoiceConnectionStatus,
} from '@discordjs/voice';

class VoiceService {
async joinVoice(interaction) {
const voiceConnection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});
let resource = createAudioResource('src/assets/767624__looplicator__short-track-1300-industraumatic.mp3', { inlineVolume: true });
if (resource.volume) {
resource.volume.setVolume(0.8);
}

player.play(resource);
voiceConnection.on(VoiceConnectionStatus.Ready, () => {
console.log('Voice ready');
});

player.on('error', error => {
console.error(`Player error: ${error.message}`);
});

player.on(AudioPlayerStatus.Idle, () => {
console.log('Idle ' + new Date());
player.play(resource);
});

player.on(AudioPlayerStatus.Buffering, () => {
console.log('Buffering ' + new Date());
});

player.on(AudioPlayerStatus.Playing, () => {
console.log('Playing ' + new Date());
});

player.on(AudioPlayerStatus.AutoPaused, () => {
console.log('AutoPaused ' + new Date());
});

player.on(AudioPlayerStatus.Paused, () => {
console.log('Paused ' + new Date());
});

voiceConnection.on('stateChange', (oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});
}
}

const voiceService = new VoiceService();
export { voiceService };
ts

import {
createAudioPlayer,
createAudioResource,
joinVoiceChannel,
NoSubscriberBehavior,
AudioPlayerStatus,
VoiceConnectionStatus,
} from '@discordjs/voice';

class VoiceService {
async joinVoice(interaction) {
const voiceConnection = joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
},
});
let resource = createAudioResource('src/assets/767624__looplicator__short-track-1300-industraumatic.mp3', { inlineVolume: true });
if (resource.volume) {
resource.volume.setVolume(0.8);
}

player.play(resource);
voiceConnection.on(VoiceConnectionStatus.Ready, () => {
console.log('Voice ready');
});

player.on('error', error => {
console.error(`Player error: ${error.message}`);
});

player.on(AudioPlayerStatus.Idle, () => {
console.log('Idle ' + new Date());
player.play(resource);
});

player.on(AudioPlayerStatus.Buffering, () => {
console.log('Buffering ' + new Date());
});

player.on(AudioPlayerStatus.Playing, () => {
console.log('Playing ' + new Date());
});

player.on(AudioPlayerStatus.AutoPaused, () => {
console.log('AutoPaused ' + new Date());
});

player.on(AudioPlayerStatus.Paused, () => {
console.log('Paused ' + new Date());
});

voiceConnection.on('stateChange', (oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});
}
}

const voiceService = new VoiceService();
export { voiceService };
1 Reply
d.js toolkit
d.js toolkit2w ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Want results from more Discord servers?
Add your server