Sug/ar/Dad/dy
Sug/ar/Dad/dy
DIAdiscord.js - Imagine an app
Created by Sug/ar/Dad/dy on 1/3/2025 in #djs-voice
Query
How to update volume of a running audio track also to seek it? I checked out the docs, didn't help me.
3 replies
DIAdiscord.js - Imagine an app
Created by Sug/ar/Dad/dy on 1/2/2025 in #djs-voice
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.');
});
9 replies