我想让那个不和谐的机器人为 ex 发送消息间隔。在 10 分钟内,但它会引发错误!请帮我!(对不起我的英语并不完美)
这是代码:
const Commando = require('discord.js-commando');
const bot = new Commando.Client({commandPrefix: '$'});
const TOKEN = 'here is token';
const MIN_INTERVAL = 100;
bot.registry.registerGroup('connectc', 'Connectc');
bot.registry.registerGroup('defaultc', 'Defaultc');
bot.registry.registerDefaults();
bot.registry.registerCommandsIn(__dirname + "/commands")
bot.on('ready', function(){
console.log("Ready");
});
setInterval(function(){
var generalChannel = bot.channels.get("542082004821213197"); // Replace with known channel ID
generalChannel.send("Hello, world!") ;
}, MIN_INTERVAL);
bot.login(TOKEN);
它抛出了这个错误
PS C:\Users\User\Documents\Visual Studio Code\Discord Bots\VblacqeBot> node .
C:\Users\User\Documents\Visual Studio Code\Discord Bots\VblacqeBot\index.js:18
generalChannel.send("Eldo!") ;
^
TypeError: Cannot read property 'send' of undefined
at eldo (C:\Users\User\Documents\Visual Studio Code\Discord Bots\VblacqeBot\index.js:18:20)
at Object.<anonymous> (C:\Users\User\Documents\Visual Studio Code\Discord Bots\VblacqeBot\index.js:28:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
PS C:\Users\User\Documents\Visual Studio Code\Discord Bots\VblacqeBot>