From 063d28520d133dd60a43be0643327126e0cefc40 Mon Sep 17 00:00:00 2001 From: DxsSucuk Date: Tue, 20 Dec 2022 23:36:02 +0100 Subject: [PATCH] Implemented a fix for #217 Fixed missing Language resource. --- languages/en-GB.yml | 3 +- .../ree6/commands/impl/mod/Blacklist.java | 4 +- .../de/presti/ree6/events/MenuEvents.java | 82 +++++++++++++++++-- 3 files changed, 79 insertions(+), 10 deletions(-) diff --git a/languages/en-GB.yml b/languages/en-GB.yml index 0e7134d49..c67588977 100644 --- a/languages/en-GB.yml +++ b/languages/en-GB.yml @@ -1,7 +1,7 @@ language: name: "English (UK)" locale: "en-GB" - version: "2.1.8" + version: "2.1.9" author: "Presti" logging: banned: ":airplane_departure: %s **banned.**" @@ -175,6 +175,7 @@ label: error: "Error" game: "Game" viewer: "Viewer" + more: "More" message: default: usage: "Usage {guild_prefix}%s." diff --git a/src/main/java/de/presti/ree6/commands/impl/mod/Blacklist.java b/src/main/java/de/presti/ree6/commands/impl/mod/Blacklist.java index 18d3aeba9..c2ca724c8 100644 --- a/src/main/java/de/presti/ree6/commands/impl/mod/Blacklist.java +++ b/src/main/java/de/presti/ree6/commands/impl/mod/Blacklist.java @@ -66,11 +66,11 @@ public void onPerform(CommandEvent commandEvent) { commandEvent.reply(commandEvent.getResource("message.blacklist.addedList","```" + end + "```"), 5); } else { ModerationUtil.blacklist(commandEvent.getGuild().getId(), commandEvent.getArguments()[1]); - commandEvent.reply(commandEvent.getResource("message.blacklist.list.added", commandEvent.getArguments()[1]), 5); + commandEvent.reply(commandEvent.getResource("message.blacklist.added", commandEvent.getArguments()[1]), 5); } } else if(commandEvent.getArguments()[0].equalsIgnoreCase("remove")) { ModerationUtil.removeBlacklist(commandEvent.getGuild().getId(), commandEvent.getArguments()[1]); - commandEvent.reply(commandEvent.getResource("message.blacklist.list.removed", commandEvent.getArguments()[1]), 5); + commandEvent.reply(commandEvent.getResource("message.blacklist.removed", commandEvent.getArguments()[1]), 5); } else { commandEvent.reply(commandEvent.getResource("message.default.invalidQuery"), 5); commandEvent.reply(commandEvent.getResource("message.default.usage","blacklist add/remove/list"),5); diff --git a/src/main/java/de/presti/ree6/events/MenuEvents.java b/src/main/java/de/presti/ree6/events/MenuEvents.java index 5f6a399be..953671d32 100644 --- a/src/main/java/de/presti/ree6/events/MenuEvents.java +++ b/src/main/java/de/presti/ree6/events/MenuEvents.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.*; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; /** * EventHandler for Menu Events. @@ -831,8 +832,23 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even return; } + String value = event.getInteraction().getValues().get(0); + EmbedBuilder embedBuilder = new EmbedBuilder(event.getMessage().getEmbeds().get(0)); + if (value.equalsIgnoreCase("more")) { + java.util.List optionList = new ArrayList<>(); + + for (TextChannel channel : event.getGuild().getTextChannels().stream().skip(24).toList()) { + optionList.add(SelectOption.of(channel.getName(), channel.getId())); + } + + embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.ticket.setupDescription")); + + event.editMessageEmbeds(embedBuilder.build()).setActionRow(new StringSelectMenuImpl("setupTickets", LanguageService.getByGuild(event.getGuild(), "label.selectChannel"), 1, 1, false, optionList)).queue(); + return; + } + MessageChannel messageChannel = event.getGuild().getTextChannelById(event.getInteraction().getValues().get(0)); if (messageChannel != null) { @@ -882,7 +898,12 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even case "ticketsSetup" -> { for (TextChannel channel : event.getGuild().getTextChannels()) { - optionList.add(SelectOption.of("%1.25s".formatted(channel.getName()), channel.getId())); + if (optionList.size() == 24) { + optionList.add(SelectOption.of(LanguageService.getByGuild(event.getGuild(), "label.more"), "more")); + break; + } + + optionList.add(SelectOption.of(channel.getName(), channel.getId())); } embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.ticket.setupDescription")); @@ -916,9 +937,24 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even return; } + String value = event.getInteraction().getValues().get(0); + EmbedBuilder embedBuilder = new EmbedBuilder(event.getMessage().getEmbeds().get(0)); - VoiceChannel voiceChannel = event.getGuild().getVoiceChannelById(event.getInteraction().getValues().get(0)); + if (value.equalsIgnoreCase("more")) { + java.util.List optionList = new ArrayList<>(); + + for (VoiceChannel channel : event.getGuild().getVoiceChannels().stream().skip(24).toList()) { + optionList.add(SelectOption.of(channel.getName(), channel.getId())); + } + + embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.temporalVoice.setupDescription")); + + event.editMessageEmbeds(embedBuilder.build()).setActionRow(new StringSelectMenuImpl("setupTempVoicechannel", LanguageService.getByGuild(event.getGuild(), "label.selectChannel"), 1, 1, false, optionList)).queue(); + return; + } + + VoiceChannel voiceChannel = event.getGuild().getVoiceChannelById(value); if (voiceChannel != null) { SQLSession.getSqlConnector().getSqlWorker().updateEntity(new TemporalVoicechannel(event.getGuild().getId(), voiceChannel.getId())); @@ -947,7 +983,12 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even case "tempVoiceSetup" -> { for (VoiceChannel channel : event.getGuild().getVoiceChannels()) { - optionList.add(SelectOption.of("%1.25s".formatted(channel.getName()), channel.getId())); + if (optionList.size() == 24) { + optionList.add(SelectOption.of(LanguageService.getByGuild(event.getGuild(), "label.more"), "more")); + break; + } + + optionList.add(SelectOption.of(channel.getName(), channel.getId())); } embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.temporalVoice.setupDescription")); @@ -1012,7 +1053,12 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even case "logSetup" -> { for (TextChannel channel : event.getGuild().getTextChannels()) { - optionList.add(SelectOption.of("%1.25s".formatted(channel.getName()), channel.getId())); + if (optionList.size() == 24) { + optionList.add(SelectOption.of(LanguageService.getByGuild(event.getGuild(), "label.more"), "more")); + break; + } + + optionList.add(SelectOption.of(channel.getName(), channel.getId())); } embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.auditLog.setupDescription")); @@ -1050,9 +1096,30 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even return; } + String value = event.getInteraction().getValues().get(0); + EmbedBuilder embedBuilder = new EmbedBuilder(event.getMessage().getEmbeds().get(0)); - TextChannel textChannel = event.getGuild().getTextChannelById(event.getInteraction().getValues().get(0)); + if (value.equals("more")) { + java.util.List optionList = new ArrayList<>(); + + for (TextChannel channel : event.getGuild().getTextChannels().stream().skip(24).toList()) { + if (optionList.size() == 24) { + optionList.add(SelectOption.of(LanguageService.getByGuild(event.getGuild(), "label.more"), "more")); + break; + } + + optionList.add(SelectOption.of(channel.getName(), channel.getId())); + } + + embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.auditLog.setupDescription")); + + event.editMessageEmbeds(embedBuilder.build()).setActionRow(new StringSelectMenuImpl("setupLogChannel", LanguageService.getByGuild(event.getGuild(), "label.selectChannel"), 1, 1, false, optionList)).queue(); + return; + } + + + TextChannel textChannel = event.getGuild().getTextChannelById(value); if (textChannel != null) { textChannel.createWebhook("Ree6-Logs").queue(webhook -> { @@ -1087,8 +1154,9 @@ public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent even case "backToSetupMenu" -> sendDefaultChoice(event); case "welcomeSetup" -> { - for (TextChannel channel : event.getGuild().getTextChannels()) { - optionList.add(SelectOption.of("%1.25s".formatted(channel.getName()), channel.getId())); + if (optionList.size() == 24) { + optionList.add(SelectOption.of(LanguageService.getByGuild(event.getGuild(), "label.more"), "more")); + break; } embedBuilder.setDescription(LanguageService.getByGuild(event.getGuild(), "message.welcome.setupDescription"));