© 2026 Hedgehog Software, LLC
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.'); });
Join the Discord to ask follow-up questions and connect with the community
Support server for discord.js, a Node.js module to interact with Discord's apps API.
57,666 Members