简体   繁体   English

无法在 client.on(ready) 中未使用时使用.send discord.js v14

[英]Cant use .send when its not used in client.on(ready) discord.js v14

im trying to make a bot that sends a message every 24 hours at a specific channel, but the我试图制作一个每 24 小时在特定频道发送消息的机器人,但是

client.channels.cache.get('ID').send('Test Mode');

only works in仅适用于

client.on("ready", () => {
    console.log(`Logged in as ${client.user.tag}`)

Im using crontab for the loop我使用 crontab 进行循环

Maybe you are trying to send the message when the bot is not ready?也许您正在尝试在机器人尚未准备好时发送消息?
Try to start the loop in the client.on("ready", () => {});尝试在client.on("ready", () => {});中启动循环
If it doesn't work, please send the full code (without the token)如果它不起作用,请发送完整代码(不带令牌)
Have a nice day!祝你今天过得愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM