use of com.mcmoddev.mmdbot.utilities.tricks.Trick in project MMDBot by MinecraftModDevelopment.
the class CmdAddTrick method execute.
@Override
protected void execute(final SlashCommandEvent event) {
if (!Utils.checkCommand(this, event)) {
return;
}
if (!event.isFromGuild()) {
event.deferReply(true).setContent("This command only works in a guild!").queue();
return;
}
if (!Utils.memberHasRole(event.getMember(), MMDBot.getConfig().getRole("bot_maintainer"))) {
event.deferReply(true).setContent("Only Bot Maintainers can use this command.").queue();
return;
}
Trick trick = trickType.createFromCommand(event);
Optional<Trick> originalTrick = Tricks.getTricks().stream().filter(t -> t.getNames().stream().anyMatch(n -> trick.getNames().contains(n))).findAny();
originalTrick.ifPresentOrElse(original -> {
Tricks.replaceTrick(original, trick);
event.reply("Updated trick!").mentionRepliedUser(false).setEphemeral(true).queue();
}, () -> {
Tricks.addTrick(trick);
event.reply("Added trick!").mentionRepliedUser(false).setEphemeral(true).queue();
});
}
Aggregations