Итак, я много раз искал код и собрал их все в одну вещь, которая работала, но не могла воспроизводить аудиофайлы.Итак, что я хотел сделать, это воспроизвести аудиофайл.wav на канале с разногласиями.Вот код, который я пробовал.
function playFunction(arguments, receivedMessage) {
var isReady = true;
if (isReady = true) {
isReady = false;
var voiceChannel = receivedMessage.member.voiceChannel;
var connection = voiceChannel.join();
voiceChannel.join().then(connection=> {console.log("Test")}).catch(err => console.log(err));
voiceChannel.join().then(connection=> {}).catch(err => console.log(err));
const dispatcher = connection.play('./audiofile.wav');
dispatcher.on("end", end => {voiceChannel.leave();})
}
}
Итак, ошибка, которую я получаю, как я сказал в заголовке:
const dispatcher = connection.play('./audiofile.wav');
^
TypeError: connection.play is not a function
at playFunction (rootpath\bot.js:88:35)
at processCommand (rootpath\bot.js:73:9)
at Client.client.on (rootpath\bot.js:22:9)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle rootpath\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (rootpath\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (rootpath\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (rootpath\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (rootpath\node_modules\ws\lib\event-target.js:120:16)
корневой путь - это просто путь к моемуbot.js и другие файлы.