I want to make that discord bot will send message interval for ex. in 10 minutes but it throws error! Please help me! (sorry for my english it is not perfect)
Here is code:
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);
And it throws this error
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>