use of net.robinfriedli.aiode.audio.exec.PooledTrackLoadingExecutor in project aiode by robinfriedli.
the class AbortCommand method doRun.
@Override
public void doRun() {
CommandExecutionTask commandExecutionTask = getTask();
Thread abortThread = new Thread(() -> {
if (commandExecutionTask != null) {
try {
commandExecutionTask.await();
} catch (InterruptedException ignored) {
}
}
CommandExecutionQueueManager executionQueueManager = Aiode.get().getExecutionQueueManager();
GuildContext guildContext = getContext().getGuildContext();
ThreadExecutionQueue executionQueue = executionQueueManager.getForGuild(getContext().getGuild());
PooledTrackLoadingExecutor pooledTrackLoadingExecutor = guildContext.getPooledTrackLoadingExecutor();
ReplaceableTrackLoadingExecutor replaceableTrackLoadingExecutor = guildContext.getReplaceableTrackLoadingExecutor();
if (executionQueue.isIdle() && pooledTrackLoadingExecutor.isIdle() && replaceableTrackLoadingExecutor.isIdle()) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setDescription("No commands are currently running");
getMessageService().sendTemporary(embedBuilder, getContext().getChannel());
setFailed(true);
} else {
executionQueue.abortAll();
pooledTrackLoadingExecutor.abortAll();
replaceableTrackLoadingExecutor.abort();
sendSuccess("Sent all currently running commands an interrupt signal and cancelled queued commands.");
}
});
abortThread.setName("aiode abort thread");
abortThread.setUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler());
abortThread.start();
}
Aggregations