use of net.dv8tion.jda.internal.interactions.component.ButtonImpl in project JavaBot by Java-Discord.
the class HelpChannelManager method sendThanksButtonsMessage.
private void sendThanksButtonsMessage(List<Member> potentialHelpers, ChannelReservation reservation, Interaction interaction, TextChannel channel) {
List<ItemComponent> thanksButtons = new ArrayList<>(25);
for (var helper : potentialHelpers.subList(0, Math.min(potentialHelpers.size(), 20))) {
thanksButtons.add(new ButtonImpl("help-thank:" + reservation.getId() + ":" + helper.getId(), helper.getEffectiveName(), ButtonStyle.SUCCESS, false, Emoji.fromUnicode("❤")));
}
ActionRow controlsRow = ActionRow.of(new ButtonImpl("help-thank:" + reservation.getId() + ":done", "Unreserve", ButtonStyle.PRIMARY, false, Emoji.fromUnicode("✅")), new ButtonImpl("help-thank:" + reservation.getId() + ":cancel", "Cancel", ButtonStyle.SECONDARY, false, Emoji.fromUnicode("❌")));
InteractionHook hook;
if (interaction.getType() == InteractionType.COMPONENT) {
hook = ((ButtonInteractionEvent) interaction).getHook();
} else if (interaction.getType() == InteractionType.COMMAND) {
hook = ((SlashCommandInteractionEvent) interaction).getHook();
} else {
throw new IllegalStateException("Unable to obtain Interaction Hook!");
}
hook.sendMessage(THANK_MESSAGE_TEXT).setEphemeral(true).queue();
List<ActionRow> rows = new ArrayList<>(5);
rows.add(controlsRow);
rows.addAll(MessageActionUtils.toActionRows(thanksButtons));
channel.sendMessage(THANK_MESSAGE_TEXT).setActionRows(rows).queue();
}
Aggregations