SteamWar/BungeeCore
Archiviert
13
2

Fix /bug, Discord Commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Lixfel 2024-07-06 15:13:08 +02:00
Ursprung e2024a481b
Commit dd07603fe3
3 geänderte Dateien mit 10 neuen und 9 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 1237a699ba244ecfac65478df34e714afbe2366e Subproject commit d000b8687d93eb43520bbf6685281099055eab9f

Datei anzeigen

@ -74,17 +74,17 @@ public class ChannelListener extends ListenerAdapter {
if(sender.user().getDiscordId() == null) if(sender.user().getDiscordId() == null)
return; return;
VelocityCore.getLogger().log(Level.INFO, "%s -> executed Discord command /%s %s".formatted(sender.user().getUserName(), event.getName(), event.getOption(DiscordBot.ARGUMENT_NAME).getAsString()));
SWCommand command = DiscordBot.getCommands().get(event.getName());
UserPerm permission = command.getPermission();
if(permission != null && !sender.user().perms().contains(permission))
return;
OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME); OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME);
String args = ""; String args = "";
if(option != null) if(option != null)
args = option.getAsString(); args = option.getAsString();
VelocityCore.getLogger().log(Level.INFO, "%s -> executed Discord command /%s %s".formatted(sender.user().getUserName(), event.getName(), args));
SWCommand command = DiscordBot.getCommands().get(event.getName());
UserPerm permission = command.getPermission();
if(permission != null && !sender.user().perms().contains(permission))
return;
command.execute(sender, args.split(" ")); command.execute(sender, args.split(" "));
}); });
} }

Datei anzeigen

@ -32,6 +32,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.entities.Emoji;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
@ -83,8 +84,8 @@ public class DiscordTicketHandler extends ListenerAdapter {
@Override @Override
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) { public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
TextChannel channel = event.getTextChannel(); MessageChannel messageChannel = event.getChannel();
if(channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) { if(messageChannel instanceof TextChannel channel && channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) {
LinkedList<StringBuilder> messages = channel.getIterableHistory().complete().stream() LinkedList<StringBuilder> messages = channel.getIterableHistory().complete().stream()
.filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot()) .filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot())
.map(message -> { .map(message -> {