我正在尝试编写音乐机器人。我想做一个播放代码。我写下了代码行,但是没有用。 我没有收到任何错误,但是音乐没有开始。
bot.on('message', async message =>{
let args = message.content.substring(PREFIX.length).split(" ");
if(message.content === '--play') {
// If the user isn't in a voice channel
if(!message.member.voice.channel) return message.channel.send('You need to be in a voice channel.')
// If the bot is already in a voice channel
if(message.guild.me.voice.channel) return message.channel.send('I am already in a voice channel')
// If no URL given
if(!args[1]) return message.channel.send('You need to input a URL.')
const connection = await message.member.voice.channel.join()
;connection.play(ytdl(args[1], {filter: 'audioonly'}))
}