Javascript 侦听器参数必须是function类型。收到未定义的错误
我的代码有点问题,错误如下:Javascript 侦听器参数必须是function类型。收到未定义的错误,javascript,Javascript,我的代码有点问题,错误如下: events.js:111 throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined ?[90m at checkListener (e
events.js:111
throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
?[90m at checkListener (events.js:111:11)?[39m
?[90m at _addListener (events.js:348:3)?[39m
?[90m at Client.addListener (events.js:406:10)?[39m
at Object.<anonymous> (C:\Users\USER\Desktop\discordjs\index.js:23:8)
?[90m at Module._compile (internal/modules/cjs/loader.js:1137:30)?[39m
?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)?[39m
?[90m at Module.load (internal/modules/cjs/loader.js:985:32)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:878:14)?[39m
?[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)?[39m
?[90m at internal/main/run_main_module.js:17:47?[39m {
code: ?[32m'ERR_INVALID_ARG_TYPE'?[39m
}
有人知道怎么修吗?我将非常感谢。您想要client.on(“message”,async message=>{…})
而不是client.on(“message”),async message=>{…}不将第二个参数传递给
上的。
client.on("message"), async message => {
const prefix = ">";
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd === "ping") {
const msg = await message.channel.send(":ping_pong: Pong!")
msg.edit(`:ping_pong: Pong!\nLatency Is ${Math.floor(msg.createdAt - message.createdAt)}\nAPI Latency ${Math.round(client.ws.ping)}ms`);
}
};