Start of CompletableFuture refactor
This commit is contained in:
parent
9cdf7e866c
commit
23d3c3c904
@ -17,6 +17,7 @@ import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.entity.server.Server;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.SQLException;
|
||||
@ -51,15 +52,10 @@ public class CreateGalleryCommand extends Command { // TODO: This command needs
|
||||
// Store the gallery channel in the database.
|
||||
|
||||
String channelId = ctx.getChannel().getIdAsString();
|
||||
try {
|
||||
if (GalleryController.galleryExists(channelId)) {
|
||||
if (GalleryController.galleryExists(channelId).join()) { // This is a value that is needed immediately.
|
||||
ctx.reply("A gallery already exists in this channel, can not create a new one.");
|
||||
return;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
ctx.reply(String.format("Error: %s", e.getMessage())); // TODO: error logging.
|
||||
return;
|
||||
}
|
||||
|
||||
String tag = ctx.getArgs()[0];
|
||||
|
||||
@ -74,12 +70,7 @@ public class CreateGalleryCommand extends Command { // TODO: This command needs
|
||||
|
||||
ctx.getChannel().asServerTextChannel().ifPresent(channel -> gallery.channelName = channel.getName());
|
||||
|
||||
try {
|
||||
GalleryController.insert(gallery);
|
||||
} catch(SQLException e) {
|
||||
ctx.reply(String.format("Error: %s", e.getMessage())); // TODO: error logging.
|
||||
return;
|
||||
}
|
||||
GalleryController.insert(gallery).exceptionally(ExceptionLogger.get()); // Make a discord exception logger for the thingos
|
||||
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setColor(Color.GREEN)
|
||||
|
@ -23,6 +23,7 @@ import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
public class ShowGalleriesCommand extends Command {
|
||||
@Override public String name() { return "Show Galleries"; }
|
||||
@ -39,13 +40,11 @@ public class ShowGalleriesCommand extends Command {
|
||||
}
|
||||
|
||||
ctx.getServer().ifPresent(server -> {
|
||||
try {
|
||||
Collection<GalleryChannel> galleries = GalleryController.getGalleriesByServer(server.getIdAsString());
|
||||
GalleryController.getGalleriesByServer(server.getIdAsString())
|
||||
.exceptionally(ExceptionLogger.get())
|
||||
.thenAccept(galleries -> {
|
||||
ctx.reply(galleryEmbed(galleries, server));
|
||||
} catch (SQLException e) {
|
||||
ctx.reply("An exception has occurred: " + e.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user