You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Add a method that check disabled and enabled methods before running the button's code
/* * Copyright (c) 2021 - 2022. Greazi - All rights reservered * * Unauthorized copying of this file, via any medium is strictly prohibited * Proprietary and confidential */packagecom.greazi.discordbotfoundation.handlers.buttons;
importcom.greazi.discordbotfoundation.debug.Debugger;
importcom.greazi.discordbotfoundation.settings.SimpleSettings;
importcom.greazi.discordbotfoundation.utils.SimpleEmbedBuilder;
importnet.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
importnet.dv8tion.jda.api.hooks.ListenerAdapter;
importnet.dv8tion.jda.api.hooks.SubscribeEvent;
importorg.jetbrains.annotations.NotNull;
importjava.util.HashMap;
importjava.util.Objects;
// TODO: Make a proper debug message returnpublicclassButtonHandlerextendsListenerAdapter {
privatefinalHashMap<String, SimpleButton> buttonList = newHashMap<>();
publicButtonHandleraddButtonListener(SimpleButtonmodule) {
buttonList.put(module.getbutton(), module);
returnthis;
}
// TODO: Add a method that check disabled and enabled methods before running the button's code@Override@SubscribeEventpublicvoidonButtonInteraction(@NotNullButtonInteractionEventevent) {
Debugger.debug("Buttons", "A button has been pressed");
// Retrieve the command class from the command that has been runSimpleButtonmodule = buttonList.get(event.getId());
if (module == null) {
event.replyEmbeds(newSimpleEmbedBuilder("ERROR - button not found")
.text("The button you used does not exist or hasn't been activated!",
"Please contact an admin and report this error!")
.error()
.setFooter("")
.build()).setEphemeral(true).queue();
return;
}
Debugger.debug("Buttons", "Found event; " + module);
if (module.getGuildOnly() && !Objects.requireNonNull(event.getGuild()).getId().equals(SimpleSettings.Bot.MainGuild())){
return;
}
if (event.getTextChannel().isNSFW() && !module.getNsfwOnly()){
return;
}
Debugger.debug("Button", " Executing command logic");
module.execute(event);
}
}
The text was updated successfully, but these errors were encountered:
Discord_Bot_Foundation/src/main/java/com/greazi/discordbotfoundation/handlers/buttons/ButtonHandler.java
Line 35 in 32b42ad
The text was updated successfully, but these errors were encountered: