Page MenuHomedesp's stash

Shutdown.java
No OneTemporary

Shutdown.java

package me.despawningbone.discordbot.command.admin;
import java.util.concurrent.TimeUnit;
import me.despawningbone.discordbot.DiscordBot;
import me.despawningbone.discordbot.command.Command;
import me.despawningbone.discordbot.command.CommandResult;
import me.despawningbone.discordbot.command.CommandResult.CommandResultType;
import me.despawningbone.discordbot.command.music.AudioTrackHandler;
import me.despawningbone.discordbot.command.music.Music;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
public class Shutdown extends Command {
public Shutdown() {
this.desc = "Shut down the bot";
this.usage = "";
this.botUserLevel = BotUserLevel.BOT_OWNER.ordinal();
}
@Override
public CommandResult execute(TextChannel channel, User author, Message msg, String[] args) {
channel.sendMessage("Bye!").queue();
System.out.println("\nShutting down the bot...\n");
AudioTrackHandler ap = ((Music) DiscordBot.commands.get("music")).getAudioTrackHandler();
if(ap != null) {
ap.ex.schedule(() -> DiscordBot.mainJDA.shutdown(), 500, TimeUnit.MILLISECONDS); //delay needed to actually shutdown correctly; borrowing the scheduler lmao
ap.shutdown();
} else {
DiscordBot.mainJDA.shutdown();
}
return new CommandResult(CommandResultType.SUCCESS);
}
}

File Metadata

Mime Type
text/x-java
Expires
Fri, Apr 3, 9:49 PM (1 d, 6 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6d/d1/50725b8218d7563c9825d7034f77

Event Timeline