Compare commits

..

No commits in common. "fddabae3c3453546cc82a4c69cd828c6ed8007a8" and "b43b882cab91b71cd105c47f144f42026bb70a6e" have entirely different histories.

3 changed files with 10 additions and 20 deletions

View File

@ -5,8 +5,8 @@ import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.requests.GatewayIntent;
import sun.misc.Signal;
import wtf.beatrice.hidekobot.listeners.MessageListener;
import wtf.beatrice.hidekobot.listeners.MessageLogger;
import wtf.beatrice.hidekobot.listeners.SlashCommandListener;
import wtf.beatrice.hidekobot.utils.Logger;
import wtf.beatrice.hidekobot.utils.SlashCommandsUtil;
@ -15,8 +15,6 @@ import javax.security.auth.login.LoginException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class HidekoBot
{
@ -72,8 +70,8 @@ public class HidekoBot
jda.addEventListener(new MessageListener());
jda.addEventListener(new SlashCommandListener());
// update slash commands (delayed)
Executors.newSingleThreadScheduledExecutor().schedule(SlashCommandsUtil::updateSlashCommands, 5, TimeUnit.SECONDS);
// update slash commands
SlashCommandsUtil.updateSlashCommands(jda);
// set the bot's status
jda.getPresence().setStatus(OnlineStatus.ONLINE);
@ -90,9 +88,6 @@ public class HidekoBot
// print the bot logo.
logger.log("\n\n" + logger.getLogo() + "\nv" + version + " - bot is ready!\n", 2);
// register shutdown interrupt signal listener for proper shutdown.
Signal.handle(new Signal("INT"), signal -> shutdown());
// log the invite-link to console so noob users can just click on it.
logger.log("Bot User ID: " + botUserId, 3);
logger.log("Invite Link: " + standardInviteLink, 4);
@ -103,11 +98,4 @@ public class HidekoBot
return jda;
}
public static void shutdown()
{
logger.log("WARNING! Shutting down!");
jda.shutdown();
System.exit(0);
}
}

View File

@ -111,7 +111,12 @@ public class MessageListener extends ListenerAdapter
channel.sendMessage("Going to sleep! Cya :sparkles:").queue();
Executors.newSingleThreadScheduledExecutor().schedule(HidekoBot::shutdown, 3, TimeUnit.SECONDS);
Executors.newSingleThreadScheduledExecutor().schedule(() ->
{
logger.log("WARNING! Shutting down!");
HidekoBot.getAPI().shutdown();
System.exit(0);
}, 5, TimeUnit.SECONDS);
return;
}

View File

@ -4,7 +4,6 @@ import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.interactions.commands.Command;
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
import wtf.beatrice.hidekobot.HidekoBot;
import wtf.beatrice.hidekobot.listeners.MessageListener;
import java.util.ArrayList;
@ -21,10 +20,8 @@ public class SlashCommandsUtil
add(Commands.slash("coinflip", "Flip a coin and get head or tails."));
}};
public static void updateSlashCommands()
public static void updateSlashCommands(JDA jdaInstance)
{
JDA jdaInstance = HidekoBot.getAPI();
List<CommandData> toAdd = new ArrayList<>();
List<Command> toDelete = new ArrayList<>();