Update OutfitInfo Command for database changes
This commit is contained in:
parent
5831720ca5
commit
1a7b6c6ada
@ -6,6 +6,7 @@
|
|||||||
package dev.salmonllama.fsbot.commands.staff;
|
package dev.salmonllama.fsbot.commands.staff;
|
||||||
|
|
||||||
import dev.salmonllama.fsbot.config.BotConfig;
|
import dev.salmonllama.fsbot.config.BotConfig;
|
||||||
|
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||||
import dev.salmonllama.fsbot.guthix.Command;
|
import dev.salmonllama.fsbot.guthix.Command;
|
||||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||||
@ -15,6 +16,7 @@ import dev.salmonllama.fsbot.utilities.database.DatabaseUtilities;
|
|||||||
import dev.salmonllama.fsbot.utilities.exceptions.DiscordError;
|
import dev.salmonllama.fsbot.utilities.exceptions.DiscordError;
|
||||||
import dev.salmonllama.fsbot.utilities.exceptions.OutfitNotFoundException;
|
import dev.salmonllama.fsbot.utilities.exceptions.OutfitNotFoundException;
|
||||||
import org.javacord.api.entity.channel.TextChannel;
|
import org.javacord.api.entity.channel.TextChannel;
|
||||||
|
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -28,28 +30,33 @@ public class OutfitInfoCommand extends Command {
|
|||||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.ROLE, BotConfig.STAFF_ROLE); }
|
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.ROLE, BotConfig.STAFF_ROLE); }
|
||||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("outfitinfo", "oinfo")); }
|
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("outfitinfo", "oinfo")); }
|
||||||
|
|
||||||
private final DatabaseUtilities db;
|
|
||||||
|
|
||||||
public OutfitInfoCommand(DatabaseUtilities db) {
|
|
||||||
this.db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandContext ctx) {
|
public void onCommand(CommandContext ctx) {
|
||||||
String[] args = ctx.getArgs();
|
String[] args = ctx.getArgs();
|
||||||
DiscordApi api = ctx.getApi();
|
|
||||||
TextChannel channel = ctx.getChannel();
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
channel.sendMessage(String.format("you did that wrong. bother %s to make these more specific.", api.getOwner().join().getDiscriminatedName()));
|
ctx.reply("You must supply an outfit ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
String id = args[0];
|
||||||
channel.sendMessage(db.getOutfitFromId(args[0]).generateInfo());
|
OutfitController.findById(id).thenAcceptAsync(possibleOutfit -> {
|
||||||
}
|
possibleOutfit.ifPresentOrElse(outfit -> {
|
||||||
catch (OutfitNotFoundException e) {
|
EmbedBuilder embed = new EmbedBuilder()
|
||||||
channel.sendMessage(new DiscordError(e.getMessage()).get());
|
.setTitle("Outfit Info")
|
||||||
}
|
.setThumbnail(outfit.getLink())
|
||||||
|
.setAuthor(ctx.getApi().getYourself())
|
||||||
|
.setUrl(outfit.getLink())
|
||||||
|
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||||
|
.addField("Added", outfit.getCreated().toString(), true)
|
||||||
|
.addField("Updated", outfit.getUpdated().toString(), true)
|
||||||
|
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||||
|
.addField("Deleted", outfit.isDeleted() ? "True" : "False", true)
|
||||||
|
.addField("Featured", outfit.isFeatured() ? "True" : "False", true);
|
||||||
|
ctx.reply(embed);
|
||||||
|
}, () -> {
|
||||||
|
ctx.reply("Outfit not found");
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class Guthix implements MessageCreateListener {
|
|||||||
addCommand(new GetOutfitCommand());
|
addCommand(new GetOutfitCommand());
|
||||||
addCommand(new RetagCommand(db));
|
addCommand(new RetagCommand(db));
|
||||||
addCommand(new RemoveOutfitCommand(db));
|
addCommand(new RemoveOutfitCommand(db));
|
||||||
addCommand(new OutfitInfoCommand(db));
|
addCommand(new OutfitInfoCommand());
|
||||||
addCommand(new SetStatusCommand());
|
addCommand(new SetStatusCommand());
|
||||||
addCommand(new WelcomeMessageCommand());
|
addCommand(new WelcomeMessageCommand());
|
||||||
addCommand(new ShowGalleriesCommand());
|
addCommand(new ShowGalleriesCommand());
|
||||||
|
Loading…
Reference in New Issue
Block a user