简体   繁体   English

Discord Bot Java - 我试图让我的机器人每隔一段时间发送一条消息,并且需要关于哪个事件侦听器最适合的帮助

[英]Discord Bot Java - I'm trying to have my bot send a message every so often and need help on which event listener is best suited

I want my bot to send a message randomly throughout the day.我希望我的机器人全天随机发送一条消息。 I was using the onMessageReceived event to achieve this, but that depends on a user sending a message, and I want the bot to still send a message randomly even if there hasn't been any server activity for a while.我使用 onMessageReceived 事件来实现这一点,但这取决于用户发送消息,我希望机器人仍然随机发送消息,即使有一段时间没有任何服务器活动。

Basically, what I'm hoping to find is if there's an Event Listener that fires every few seconds consistently while the bot is online .基本上,我希望找到的是,当机器人在线时,是否有一个事件侦听器每隔几秒持续触发一次 The event shouldn't be dependent on if users send messages or if people join voice channels, etc.该事件不应依赖于用户是否发送消息或人们是否加入语音频道等。

Does anyone know of an Event Listener that could help me achieve this?有谁知道可以帮助我实现这一目标的事件侦听器?

运行命令后只需在您的机器人中使用计时器,您可以添加一个命令,例如 !motd random 随机间隔,然后如果您想在一段时间后执行此操作,请执行 !motd 3hours

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

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