use of de.tectoast.emolga.commands.CommandCategory in project Emolga by TecToast.
the class HelpButton method process.
@Override
public void process(ButtonClickEvent e, String name) {
Guild g = e.getGuild();
Member mem = e.getMember();
if (name.equals("BACK")) {
EmbedBuilder builder = new EmbedBuilder();
builder.setTitle("Commands").setColor(java.awt.Color.CYAN);
builder.setDescription(getHelpDescripion(g, mem));
builder.setColor(java.awt.Color.CYAN);
e.editMessageEmbeds(builder.build()).queue();
} else {
CommandCategory c = CommandCategory.byName(name);
if (c.allowsGuild(g) && c.allowsMember(mem)) {
List<Command> l = getWithCategory(c, g, mem);
List<MessageEmbed> embeds = new LinkedList<>();
StringBuilder b = new StringBuilder();
boolean first = true;
for (Command cmd : l) {
b.append(cmd.getHelp(g)).append("\n");
if (b.length() > 1900) {
EmbedBuilder emb = new EmbedBuilder();
if (first)
emb.setTitle(c.getName());
embeds.add(emb.setColor(Color.CYAN).setDescription(b.toString()).build());
first = false;
b.setLength(0);
}
}
if (b.length() > 0) {
EmbedBuilder emb = new EmbedBuilder();
if (first)
emb.setTitle(c.getName());
embeds.add(emb.setColor(Color.CYAN).setDescription(b.toString()).build());
}
e.editMessageEmbeds(embeds).queue(i -> i.editOriginalComponents(getHelpButtons(g, mem)).queue());
} else {
e.reply("Auf die Kategorie " + c.getName() + " hast du keinen Zugriff!").queue();
}
}
}
Aggregations