Audio Issues

if(!args.join(' '))
return message.reply("Please type song name.");

let api = require(process.cwd()+'/structures/api')


const voiceChannel = message.member.voice.channel;

if (!voiceChannel) {
return message.reply('You need to join a voice channel first!');
}

const botChannel = message.guild.members.me.voice.channel;
if (botChannel && botChannel.id !== voiceChannel.id) {
return message.reply('I am already in another voice channel!');
}

if (!botChannel) {
joinVoiceChannel({
channelId: voiceChannel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
}
let song = await api.searchSong(args.join(' '))

const url = song.streamUrl;
const player = createAudioPlayer();
const resource = createAudioResource(url, {
inputType: StreamType.Arbitrary,
});

player.play(resource);
return entersState(player, AudioPlayerStatus.Playing, 5000);
const embed = new EmbedBuilder()
.setColor('Green')
.setDescription(`Now playing: ${url}`);

message.reply({ embeds: [embed] });

player.on(AudioPlayerStatus.Idle, () => {
message.channel.send('Song has finished playing.');
});

player.on('error', error => {
console.error(error);
message.channel.send('An error occurred while trying to play the audio.');
});
if(!args.join(' '))
return message.reply("Please type song name.");

let api = require(process.cwd()+'/structures/api')


const voiceChannel = message.member.voice.channel;

if (!voiceChannel) {
return message.reply('You need to join a voice channel first!');
}

const botChannel = message.guild.members.me.voice.channel;
if (botChannel && botChannel.id !== voiceChannel.id) {
return message.reply('I am already in another voice channel!');
}

if (!botChannel) {
joinVoiceChannel({
channelId: voiceChannel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
}
let song = await api.searchSong(args.join(' '))

const url = song.streamUrl;
const player = createAudioPlayer();
const resource = createAudioResource(url, {
inputType: StreamType.Arbitrary,
});

player.play(resource);
return entersState(player, AudioPlayerStatus.Playing, 5000);
const embed = new EmbedBuilder()
.setColor('Green')
.setDescription(`Now playing: ${url}`);

message.reply({ embeds: [embed] });

player.on(AudioPlayerStatus.Idle, () => {
message.channel.send('Song has finished playing.');
});

player.on('error', error => {
console.error(error);
message.channel.send('An error occurred while trying to play the audio.');
});
2 Replies
d.js toolkit
d.js toolkit4w 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
Sug/ar/Dad/dy
Sug/ar/Dad/dyOP3w ago
Bot does join the channel. But doesn't plays the audio
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.18.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.7

Encryption Libraries
- sodium-native: 3.4.1
- sodium: not found
- libsodium-wrappers: not found
- @stablelib/xchacha20poly1305: not found
- @noble/ciphers: not found

FFmpeg
- version: 4.3.7-0+deb11u1
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.18.0
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.7

Encryption Libraries
- sodium-native: 3.4.1
- sodium: not found
- libsodium-wrappers: not found
- @stablelib/xchacha20poly1305: not found
- @noble/ciphers: not found

FFmpeg
- version: 4.3.7-0+deb11u1
- libopus: yes
--------------------------------------------------
Unfortunately the stream url is MP4 but without video It is direct link to an MP4 file Probably one of the cdn server of a big music app Maybe but I use their official api C'mon chill

Did you find this page helpful?