我正在为我的不和谐服务器编码一个机器人,正如标题中所述,我正在尝试使用VoiceConnection.play方法在语音通道中播放音乐。 但是我总是会遇到此错误:'TypeError:无法将“ null”转换为int'。
这是我的代码:
const Command = require("./command");
module.exports = class Play extends Command {
static match (message) {
console.log("checking play");
return message.content.startsWith("!play");
}
static action (message) {
let voiceChannel = message.guild.channels.cache.filter(channel => channel.type === "voice").first();
voiceChannel.join()
.then(connection => {
connection.play(ytdl('https://www.youtube.com/watch?v=ZlAU_w7-Xp8', { quality: 'highestaudio' }));
})
.catch(console.error);
}
}
这是我的依赖项
"dependencies": {
"discord.js": "^12.0.2",
"ffmpeg-static": "^4.0.1",
"opusscript": "0.0.7",
"ytdl-core": "^2.0.1"
}
完整的错误消息:
TypeError: Cannot convert "null" to int
TypeError: Cannot convert "null" to int
C:\Users\Charly\Desktop\henallux\bloc3\bot\node_modules\opusscript\build\opusscript_native_wasm.js:8
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var
ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){
abort(TypeError: Cannot convert "null" to int). Build with -s ASSERTIONS=1 for more info.