Проблем с какими-то командами нет. Дело в том, что когда ввожу название песни, бот ее находит, все четко, а когда заходит ко мне в голосовой, видно по зеленой окантовке что какие - то звуки произносит по идее, но ничего такого не слышно. Вот код на всякий:
const { Player } = require("discord-player");
// Create a new Player (you don't need any API Key)
const player = new Player(client);
// To easily access the player
client.player = player;
// add the trackStart event so when a song will be played this message will be sent
client.player.on('trackStart', (message, track) => message.channel.send(`Now playing ${track.title}...`))
client.on("ready", () => {
console.log("I'm ready !");
});
client.on("message", async (message) => {
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
// !play Despacito
// will play "Despacito" in the member voice channel
if(command === "play"){
client.player.play(message, args[0], message.member.user);
// as we registered the event above, no need to send a success message here
}
});
client.player
// Send a message when a track starts
.on('trackStart', (message, track) => message.channel.send(`Now playing ${track.title}...`))
// Send a message when something is added to the queue
.on('trackAdd', (message, track) => message.channel.send(`${track.title} has been added to the queue!`))
.on('playlistAdd', (message, playlist) => message.channel.send(`${playlist.title} has been added to the queue (${playlist.items.length} songs)!`))
// Send messages to format search results
.on('searchResults', (message, query, tracks) => {
const embed = new Discord.MessageEmbed()
.setAuthor(`Here are your search results for ${query}!`)
.setDescription(tracks.map((t, i) => `${i}. ${t.title}`))
.setFooter('Send the number of the song you want to play!')
message.channel.send(embed);
})
.on('searchInvalidResponse', (message, query, tracks, content, collector) => message.channel.send(`You must send a valid number between 1 and ${tracks.length}!`))
.on('searchCancel', (message, query, tracks) => message.channel.send('You did not provide a valid response... Please send the command again!'))
.on('noResults', (message, query) => message.channel.send(`No results found on YouTube for ${query}!`))
// Send a message when the music is stopped
.on('queueEnd', (message, queue) => message.channel.send('Music stopped as there is no more music in the queue!'))
.on('channelEmpty', (message, queue) => message.channel.send('Music stopped as there is no more member in the voice channel!'))
.on('botDisconnect', (message, queue) => message.channel.send('Music stopped as I have been disconnected from the channel!'))
// Error handling
.on('error', (error, message) => {
switch(error){
case 'NotPlaying':
message.channel.send('There is no music being played on this server!')
break;
case 'NotConnected':
message.channel.send('You are not connected in any voice channel!')
break;
case 'UnableToJoin':
message.channel.send('I am not able to join your voice channel, please check my permissions!')
break;
default:
message.channel.send(`Something went wrong... Error: ${error}`)
}
})