javascript - Discord js bot connection.play() 不会播放音频文件
问题描述
我今天刚刚安装/更新了所有东西。我更新了 Visual Studio 并安装了 Node js、Discord js 和 ffmpeg 音频路径。但是我不能让不和谐机器人播放音频。是的,机器人仍然连接到呼叫,并且具有相同设置的其他脚本也工作得很好。但这似乎不起作用。我有以下控制台行“console.log(connection.play);” 在控制台中有以下输出。一切似乎都应该起作用,但事实并非如此。
以下是我的代码。
module.exports = {
name: 'rickroll',
description: "never gonna give you up",
execute(message, args) {
if (isReady) {
isReady = false;
var voiceChannel = message.member.voice.channel;
console.log('isReady: ' + isReady)
if (!voiceChannel) {
return message.reply("You are not in a voice channel");
}
voiceChannel.join().then(connection => {
const dispatcher = connection.play('/discordBot/Rick.mp3', { volume: 0.5 });
console.log(connection.play);
console.log('currently playing!');
dispatcher.on("end", end => {
voiceChannel.leave();
isReady = true;
message.channel.send("The bot is done!");
});
}).catch(error => console.log(error));
}
}
}
如果它看起来很乱也很抱歉,今天是我写java脚本的第一天。
解决方案
推荐阅读
- javascript - React Native:在 React Native 应用程序的发布 apk 上获得“无效的钩子调用”
- python - 如何在图形 Matplotlib 中显示 x 或 y 值?
- python - 使用字符串示例在 C 和 Python 中使用 ctypes 进行内存管理和消除泄漏
- arrays - Pyspark:如何选择有条件的数据框
- windows - Windows .bat 脚本:打开 VSCODE 并在终端中运行 npm start
- python - 无法将熊猫数据框转换为 csv 文件
- reactjs - 如何设置 React-Select 样式
- python - 使用 .click() 或 .move_to_element() Selenium Python 模拟鼠标移动
- c++ - C++ 中的数组排序问题
- python - 如何在给定点列表并添加边权重的情况下制作networkX网格?