Question for "Event Setup" #71
-
For the const { Events } = require('discord.js');
module.exports = {
name: Events.ClientReady,
once: true,
execute(client) {
console.log('Immediately runs w/o anything triggered');
// Looking to have this work with CommandKit.
},
}; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello. I'm a bit confused when you mention "immediately run". Do you want to:
Here's how you can achieve both of the above: For 1:To run code without any event being triggered (including "ready"), CommandKit doesn't really provide any way to handle this situation since it's out of the scope of handling commands/events with Discord.js. You can achieve this pretty easily however by placing your code anywhere before logging in to your client/bot. // File: src/index.ts
// ... rest of your code
function main() {
console.log('This will run immediately when the app starts without waiting for the bot to start up');
}
main();
client.login('your-token-here'); For 2:To run code immediately after your bot has gone online, you can make use of the "ready" event provided by Discord.js. If you're trying to handle this event using CommandKit:
Let me know if this solves your issue. |
Beta Was this translation helpful? Give feedback.
Hello.
I'm a bit confused when you mention "immediately run". Do you want to:
Here's how you can achieve both of the above:
For 1:
To run code without any event being triggered (including "ready"), CommandKit doesn't really provide any way to handle this situation since it's out of the scope of handling commands/events with Discord.js. You can achieve this pretty easily however by placing your code anywhere before logging in to your client/bot.