Make random statuses update automatically
This commit is contained in:
parent
b1b62bab9f
commit
9e1888611a
@ -18,6 +18,7 @@ import wtf.beatrice.hidekobot.listeners.SlashCommandCompletionListener;
|
|||||||
import wtf.beatrice.hidekobot.listeners.SlashCommandListener;
|
import wtf.beatrice.hidekobot.listeners.SlashCommandListener;
|
||||||
import wtf.beatrice.hidekobot.runnables.ExpiredMessageTask;
|
import wtf.beatrice.hidekobot.runnables.ExpiredMessageTask;
|
||||||
import wtf.beatrice.hidekobot.runnables.HeartBeatTask;
|
import wtf.beatrice.hidekobot.runnables.HeartBeatTask;
|
||||||
|
import wtf.beatrice.hidekobot.runnables.StatusUpdateTask;
|
||||||
import wtf.beatrice.hidekobot.util.CommandUtil;
|
import wtf.beatrice.hidekobot.util.CommandUtil;
|
||||||
import wtf.beatrice.hidekobot.util.Logger;
|
import wtf.beatrice.hidekobot.util.Logger;
|
||||||
|
|
||||||
@ -158,7 +159,6 @@ public class HidekoBot
|
|||||||
|
|
||||||
// set the bot's status
|
// set the bot's status
|
||||||
jda.getPresence().setStatus(OnlineStatus.ONLINE);
|
jda.getPresence().setStatus(OnlineStatus.ONLINE);
|
||||||
jda.getPresence().setActivity(Activity.playing("Hatsune Miku: Project DIVA"));
|
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
logger.log("Connecting to database...");
|
logger.log("Connecting to database...");
|
||||||
@ -182,6 +182,8 @@ public class HidekoBot
|
|||||||
scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds
|
scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds
|
||||||
HeartBeatTask heartBeatTask = new HeartBeatTask();
|
HeartBeatTask heartBeatTask = new HeartBeatTask();
|
||||||
scheduler.scheduleAtFixedRate(heartBeatTask, 10, 30, TimeUnit.SECONDS); //every 30 seconds
|
scheduler.scheduleAtFixedRate(heartBeatTask, 10, 30, TimeUnit.SECONDS); //every 30 seconds
|
||||||
|
StatusUpdateTask statusUpdateTask = new StatusUpdateTask();
|
||||||
|
scheduler.scheduleAtFixedRate(statusUpdateTask, 0, 60 * 5, TimeUnit.SECONDS); // every 5 minutes
|
||||||
|
|
||||||
// register shutdown interrupt signal listener for proper shutdown.
|
// register shutdown interrupt signal listener for proper shutdown.
|
||||||
Signal.handle(new Signal("INT"), signal -> shutdown());
|
Signal.handle(new Signal("INT"), signal -> shutdown());
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package wtf.beatrice.hidekobot.runnables;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
|
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StatusUpdateTask implements Runnable
|
||||||
|
{
|
||||||
|
|
||||||
|
List<String> statuses = Arrays.asList(
|
||||||
|
"Hatsune Miku: Project DIVA",
|
||||||
|
"Wii Sports",
|
||||||
|
"Excel",
|
||||||
|
"Mii Channel",
|
||||||
|
"Wii Speak",
|
||||||
|
"MineTest",
|
||||||
|
"Mario Kart Wii"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
int randomPos = RandomUtil.getRandomNumber(0, statuses.size() - 1);
|
||||||
|
String status = statuses.get(randomPos) + " | " + Cache.getBotPrefix() + " help";
|
||||||
|
HidekoBot.getAPI().getPresence().setActivity(Activity.playing(status));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user