2022-11-20 18:56:57 +01:00
|
|
|
package wtf.beatrice.hidekobot.commands.slash;
|
2022-11-20 06:04:00 +01:00
|
|
|
|
|
|
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
2022-11-22 16:39:31 +01:00
|
|
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
2022-11-20 06:04:00 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2022-11-21 20:20:11 +01:00
|
|
|
import wtf.beatrice.hidekobot.Cache;
|
2022-11-20 06:04:00 +01:00
|
|
|
import wtf.beatrice.hidekobot.HidekoBot;
|
2022-11-22 16:41:08 +01:00
|
|
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
2022-11-20 06:04:00 +01:00
|
|
|
|
|
|
|
import java.util.concurrent.Executors;
|
2025-03-09 11:30:59 +01:00
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
2022-11-20 06:04:00 +01:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
2022-11-22 16:39:31 +01:00
|
|
|
public class DieCommand extends SlashCommandImpl
|
2022-11-20 06:04:00 +01:00
|
|
|
{
|
2022-11-22 14:32:22 +01:00
|
|
|
@Override
|
2022-11-22 16:39:31 +01:00
|
|
|
public CommandData getSlashCommandData() {
|
|
|
|
return Commands.slash("die", "Stop the bot's process.")
|
|
|
|
.setDefaultPermissions(DefaultMemberPermissions.DISABLED);
|
2022-11-22 14:32:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-11-20 22:09:58 +01:00
|
|
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
2022-11-20 06:04:00 +01:00
|
|
|
{
|
2022-11-22 00:04:34 +01:00
|
|
|
if(Cache.getBotOwnerId() != event.getUser().getIdLong())
|
2022-11-20 06:04:00 +01:00
|
|
|
{
|
|
|
|
event.reply("Sorry, only the bot owner can run this command!").setEphemeral(true).queue();
|
|
|
|
} else {
|
2022-11-20 16:07:04 +01:00
|
|
|
event.reply("Going to sleep! Cya ✨").queue();
|
2025-03-09 11:30:59 +01:00
|
|
|
try (ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor()) {
|
|
|
|
executor.schedule(HidekoBot::shutdown, 3, TimeUnit.SECONDS);
|
|
|
|
}
|
2022-11-20 06:04:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|