use of net.dv8tion.jda.api.interactions.components.ItemComponent in project MMDBot by MinecraftModDevelopment.
the class PaginatedCommand method createScrollButtons.
/**
* Create the row of Component interaction buttons.
* <p>
* Currently, this just creates a left and right arrow.
* Left arrow scrolls back a page. Right arrow scrolls forward a page.
*
* @param start The quote number at the start of the current page.
* @return A row of buttons to go back and forth by one page.
*/
private ItemComponent[] createScrollButtons(int start) {
Button backward = Button.primary(listener.getButtonID() + "-" + start + "-prev", Emoji.fromUnicode("◀️")).asDisabled();
Button forward = Button.primary(listener.getButtonID() + "-" + start + "-next", Emoji.fromUnicode("▶️")).asDisabled();
if (start != 0) {
backward = backward.asEnabled();
}
if (start + items_per_page < maximum) {
forward = forward.asEnabled();
}
return new ItemComponent[] { backward, forward };
}
use of net.dv8tion.jda.api.interactions.components.ItemComponent 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();
}
use of net.dv8tion.jda.api.interactions.components.ItemComponent in project dDiscordBot by DenizenScript.
the class DiscordMessageCommand method createRows.
public static List<ActionRow> createRows(ScriptEntry scriptEntry, ObjectTag rowsObj) {
if (rowsObj == null) {
return null;
}
Collection<ObjectTag> rows = CoreUtilities.objectToList(rowsObj, scriptEntry.getContext());
List<ActionRow> actionRows = new ArrayList<>();
for (ObjectTag row : rows) {
List<ItemComponent> components = new ArrayList<>();
for (ObjectTag component : CoreUtilities.objectToList(row, scriptEntry.getContext())) {
if (component.canBeType(DiscordButtonTag.class)) {
components.add(component.asType(DiscordButtonTag.class, scriptEntry.getContext()).build());
} else if (component.canBeType(DiscordSelectionTag.class)) {
components.add(component.asType(DiscordSelectionTag.class, scriptEntry.getContext()).build(scriptEntry.getContext()).build());
} else {
Debug.echoError("Unrecognized component list entry '" + component + "'");
}
}
actionRows.add(ActionRow.of(components));
}
return actionRows;
}
use of net.dv8tion.jda.api.interactions.components.ItemComponent in project MMDBot by MinecraftModDevelopment.
the class CmdDictionary method createScrollButtons.
private static ItemComponent[] createScrollButtons(int start, String word, int maximum) {
Button backward = Button.primary(ButtonListener.BUTTON_ID + "-" + start + "-prev-" + word + "-" + maximum, Emoji.fromUnicode("◀️")).asDisabled();
Button forward = Button.primary(ButtonListener.BUTTON_ID + "-" + start + "-next-" + word + "-" + maximum, Emoji.fromUnicode("▶️")).asDisabled();
if (start != 0) {
backward = backward.asEnabled();
}
if (start + 1 < maximum) {
forward = forward.asEnabled();
}
return new ItemComponent[] { backward, forward };
}
Aggregations