[英]Discord.js bot help needed - how can I make my bot auto do a task every 6 hours without sending it a command?
I made a bot with a command that auto assign roles to members based on stats I get from an API. 我用命令创建了一个机器人,该命令根据从API获得的统计信息自动为成员分配角色。 How do I make it so that it does that automatically every 6 hours or so without me sending a command manually? 如何使它每隔6小时自动执行一次,而无需我手动发送命令?
For example you can do something like that: 例如,您可以执行以下操作:
setInterval(function(){
client.channels.get("Channel Id").send("I will send it every 6 hours")
}, 6 * 3600000);
You need to use it in event ready. 您需要在事件就绪时使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.