我為我和我的朋友們準(zhǔn)備了這個(gè)簡(jiǎn)單的音樂機(jī)器人,但升級(jí)到discord.js的v13后,有些東西就不再工作了。。。我已經(jīng)改變了一些事情,就像discord.js指南告訴你的那樣。有人知道這里怎么了??
const ytdl = require('ytdl-core');
const Music = require('discordjs/voice');
console.log("is this working");
// PLAYER
client.on("messageCreate", async message => {
if(message.content == 'goplay') {
const url = args[0];
if(!url) return message.channel.send('no url');
const stream = ytdl(url, { filter: 'audioonly'});
const channel = message.member.voice.channel;
const player = Music.createAudioPlayer();
const ressource = Music.createAudioResource(stream);
const connection = Music.joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.channel.guild,
adapterCreator: message.guild.voiceAdapterCreator,
});
player.play(ressource)
connection.subscribe(player);
}
});
這是錯(cuò)誤消息
這看起來像一個(gè)
package.json
錯(cuò)誤。確保創(chuàng)建了一個(gè)package.json。使用命令
npm init
,并填寫所需信息,讓它使用npm init -y
自動(dòng)創(chuàng)建所有內(nèi)容(然后確保安裝所有npm軟件包)