我这里有一个小问题:
events.js:200
抛出新错误。ERR_INVALID_ARG_TYPE('listener', 'Function',listener);
^
类型错误 [ERR_INVALID_ARG_TYPE]:“侦听器”参数必须是类型
功能。收到的类型未定义
在 _addListener (events.js:200:11)
在 Client.addListener (events.js:259:10)
在对象。 (D:\Yoshio\index.js:7:5)
在 Module._compile (内部/modules/cjs/loader.js:689:30)
在 Object.Module._extensions..js (内部/模块/cjs/loader.js:700:10)
在 Module.load (内部/modules/cjs/loader.js:599:32)
在 tryModuleLoad (内部/模块/cjs/loader.js:538:12)
在 Function.Module._load (内部/modules/cjs/loader.js:530:3)
在 Function.Module.runMain (内部/modules/cjs/loader.js:742:12)
启动时(内部/bootstrap/node.js:266:19)
我寻找答案但找不到任何答案,请告诉我该怎么办。
这是我的代码:
const Discord = require("discord.js");
const TOKEN = "mytoken";
var bot = new Discord.Client();
bot.on("message"), function(message) {
console.log(message.content);
};
bot.login(TOKEN);
从您提交的代码来看,您正在关闭您的on
在将函数作为参数传递之前调用。试试这个:
const Discord = require("discord.js");
const TOKEN = "mytoken"
var bot = new Discord.Client();
/*
* Note the change here, the parenthesis is moved after
* the function declaration so your anonymous function is now
* passed as an argument.
*/
bot.on("message", function(message) {
console.log(message.content);
});
bot.login(TOKEN);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)