【发布时间】:2021-11-29 18:13:04
【问题描述】:
我为我和我的朋友们准备了这个简单的音乐机器人,但是在升级到 discord.js 的 v13 之后,有些东西就不再起作用了……我已经改变了一些东西,就像 discord.js guide 告诉你的那样做。有人知道这里出了什么问题??
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);
}
});
【问题讨论】:
-
您是否在您的机器人文件夹中创建了一个 index-voice.js(或曾经有一个)?
标签: javascript node.js discord.js voice