我在输入 node 时遇到了这个错误。启动程序。如果这是一个愚蠢的问题,我很抱歉,但我刚刚开始编码。我的代码有什么问题?
这是一个不和谐的机器人,我在网上没有看到任何关于这个问题的信息。
const discord = require ('discord.js');
var client = new discord.Client();
const token = 'E440dqHpTt1qTHw4iWB3VgXit7_tcUd4';
client.on ("ready"), () => {
console.log ("ready!");
client.user.setGame ("prefix tb")
};
const prefix = "tb"
client.on ('message', function(message) {
if (message.author.bot) return;
if (message.content.startsWith (prefix + "hello")) {
message.reply ("Hi! What's up?");
}
});
client.login (token);
我以为机器人会启动,但我得到了这个:
throw new errors.ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type undefined
at checkListener (events.js:54:11)
at _addListener (events.js:205:3)
at Client.addListener (events.js:263:10)
at Object.<anonymous> (E:\Discord Bots\tylerbot\tylerbot.js:7:8)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
一只斗牛犬
斯蒂芬大帝
相关分类