add emojis to the log category buttons and add a home button
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
This commit is contained in:
parent
188124991e
commit
4a522c084d
@ -17,6 +17,7 @@ public class Emojis {
|
||||
public static final Emoji PAUSE_EMOJI;
|
||||
public static final Emoji PLAY_EMOJI;
|
||||
public static final Emoji SKIP_EMOJI;
|
||||
public static final Emoji HOME_EMOJI;
|
||||
|
||||
/**
|
||||
* Presence Status Emojis
|
||||
@ -40,6 +41,7 @@ public class Emojis {
|
||||
PAUSE_EMOJI = Emoji.fromUnicode("⏸");
|
||||
PLAY_EMOJI = Emoji.fromUnicode("▶");
|
||||
SKIP_EMOJI = Emoji.fromUnicode("⏭");
|
||||
HOME_EMOJI = Emoji.fromUnicode("🏠");
|
||||
log.info("Loaded emojis!");
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,33 @@
|
||||
package cc.fascinated.bat.features.logging;
|
||||
|
||||
import cc.fascinated.bat.common.EnumUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
public enum LogCategory {
|
||||
MESSAGE("Message"),
|
||||
MEMBER("Member"),
|
||||
CHANNEL("Channel"),
|
||||
GUILD("Guild");
|
||||
MESSAGE(Emoji.fromUnicode("📩")),
|
||||
MEMBER(Emoji.fromUnicode("👤")),
|
||||
CHANNEL(Emoji.fromUnicode("📺")),
|
||||
GUILD(Emoji.fromUnicode("🏰"));
|
||||
|
||||
/**
|
||||
* The name of the log category
|
||||
* The emoji of the log category
|
||||
*/
|
||||
private final String name;
|
||||
private final Emoji emoji;
|
||||
|
||||
/**
|
||||
* Gets the name of the log category
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return EnumUtils.getEnumName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log category by the name
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.fascinated.bat.features.logging.command;
|
||||
|
||||
import cc.fascinated.bat.Emojis;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
@ -12,6 +13,7 @@ import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||
@ -32,30 +34,31 @@ public class ListSubCommand extends BatSubCommand implements EventListener {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||
List<Button> buttons = new ArrayList<>();
|
||||
buttons.add(Button.primary("logs-home", "Home").withEmoji(Emojis.HOME_EMOJI));
|
||||
for (LogCategory category : LogCategory.values()) {
|
||||
buttons.add(Button.primary("logs:list:%s".formatted(category.name().toLowerCase()), category.getName()));
|
||||
buttons.add(Button.primary("logs:list:%s".formatted(category.name().toLowerCase()), category.getName()).withEmoji(category.getEmoji()));
|
||||
}
|
||||
|
||||
event.replyEmbeds(EmbedUtils.genericEmbed().setDescription(new EmbedDescriptionBuilder("Log Channels")
|
||||
.appendLine("""
|
||||
Set the log channel for:
|
||||
- A specific event, use `/logs set <event> <channel>`
|
||||
- A specific category by using `/logs set <category> <channel>`
|
||||
- All log events by using `/logs set all <channel>`
|
||||
To remove a log channel, it's the same as setting it,
|
||||
but with `/logs remove` instead of `/logs set`
|
||||
|
||||
*Use the buttons below to see the log channels for each category*
|
||||
""", false).build()).build())
|
||||
.addComponents(ActionRow.of(buttons))
|
||||
.queue();
|
||||
event.replyEmbeds(getHelpMessage()).addComponents(ActionRow.of(buttons)).queue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonInteraction(BatGuild guild, @NonNull BatUser user, @NonNull ButtonInteractionEvent event) {
|
||||
if (guild == null || !event.getComponentId().startsWith("logs:list:")) { // Invalid button
|
||||
if (guild == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Home
|
||||
if (event.getComponentId().equals("logs-home")) {
|
||||
event.editMessageEmbeds(getHelpMessage()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
// Not a log category
|
||||
if (!event.getComponentId().startsWith("logs:list:")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Category
|
||||
String[] split = event.getComponentId().split(":");
|
||||
if (split.length != 3) {
|
||||
return;
|
||||
@ -79,5 +82,24 @@ public class ListSubCommand extends BatSubCommand implements EventListener {
|
||||
}
|
||||
event.editMessageEmbeds(EmbedUtils.genericEmbed().setDescription(description.build()).build()).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help message for the command
|
||||
*
|
||||
* @return the help message
|
||||
*/
|
||||
public MessageEmbed getHelpMessage() {
|
||||
return EmbedUtils.genericEmbed().setDescription(new EmbedDescriptionBuilder(null).appendLine(
|
||||
"""
|
||||
Set the log channel for:
|
||||
- A specific event, use `/logs set <event> <channel>`
|
||||
- A specific category by using `/logs set <category> <channel>`
|
||||
- All log events by using `/logs set all <channel>`
|
||||
To remove a log channel, it's the same as setting it,
|
||||
but with `/logs remove` instead of `/logs set`
|
||||
\s
|
||||
*Use the buttons below to see the log channels for each category*
|
||||
""", false).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user