简体   繁体   English

Discord.js机器人程序需要帮助-如何使我的机器人每6小时自动执行一项任务而不发送命令?

[英]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.

相关问题 如何为我的 discord.js 机器人发出禁令命令? - How can I make a ban command for my discord.js bot? 如何为我的 Discord.js 机器人创建奇偶命令? - How can I make an even-odd command for my Discord.js bot? 如何发出重置命令来重新启动我的 discord.js 机器人? - How can i make a reset command to restart my discord.js bot? 我怎样才能实现!leaveguild<guildid> 命令(离开指定的公会)进入我的 Discord (discord.js) 机器人?</guildid> - How can I implement a !leaveguild <guildID> command (that leaves the specified guild) into my Discord (discord.js) bot? 如何让我的机器人每 10 秒更改一次状态? (在线,空闲,免打扰)Discord.js - How can I make my bot change status every 10 seconds? (Online, Idle, DND) Discord.js 如何使我的 discord 机器人具有自定义状态 (discord.js) - How do I make my discord bot have a custom status (discord.js) 如何在网站上制作 discord.js 机器人统计信息? - How I can make discord.js bot statistics on website? Discord.js 如何为我的机器人所在的每个公会创建邀请? - Discord.js how can I create an invite for every guild my bot is in? discord.js 问题。 我如何让机器人对一个命令给出不同的响应? - discord.js question. how do i make the bot give a different response to one command? 我如何让机器人在不带“\\_poll”的情况下使用 discord.js 发送轮询消息的 adv poll 命令 - How do I get a bot to send the message of the poll without the '\_poll' for an adv poll command with discord.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM