gpt4 book ai didi

javascript - 使用DiscordJS的Music Discord机器人无法正常工作

转载 作者:行者123 更新时间:2023-12-03 01:41:50 28 4
gpt4 key购买 nike

我正在使用Discord.JS制作自己的discord机器人,我希望它可以让您说出“!music”以及可以播放的youtube视频的链接,但是经过一遍又一遍的测试之后,我以某种方式使其停止工作。我检查了一下,关于该漫游器的所有其他信息都起作用了,而不仅仅是音乐部分。

Note: the command is just the string of the first part of the message, arg1 is the first argument and the bot is Discord.client();


if(command === '!music') {
var link = arg1
const ytdl = require('ytdl-core');
const streamOptions = { seek: 0, volume: 1 };
const broadcast = bot.createVoiceBroadcast();

bot.voiceChannel.join()
.then(connection => {
const stream = ytdl(arg1, { filter : 'audioonly' });
broadcast.playStream(stream);
const dispatcher = connection.playBroadcast(broadcast);
})
.catch(console.error);
}

最佳答案

我发现了问题所在,当您执行其他命令时,有一个大括号使它可以执行某些命令的if语句,因此我将其修复,现在我遇到了一个新问题,它将说FFmpeg是找不到,我实际上已经安装了它,但似乎没有看到它已安装。

关于javascript - 使用DiscordJS的Music Discord机器人无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46758231/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com