From 6a42b802e72665baa61825a1f13a9fdc6c08cafa Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 28 Jun 2024 09:42:20 +0200 Subject: [PATCH] Fix DC Command logging, ChatRoom and double messages Signed-off-by: Lixfel --- .../discord/channels/DiscordChatRoom.java | 1 - .../discord/listeners/ChannelListener.java | 3 +++ .../discord/listeners/DiscordTicketHandler.java | 13 ++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/velocitycore/discord/channels/DiscordChatRoom.java b/src/de/steamwar/velocitycore/discord/channels/DiscordChatRoom.java index e09f76d7..2d5f0fb2 100644 --- a/src/de/steamwar/velocitycore/discord/channels/DiscordChatRoom.java +++ b/src/de/steamwar/velocitycore/discord/channels/DiscordChatRoom.java @@ -48,6 +48,5 @@ public class DiscordChatRoom extends DiscordChannel { } ChatListener.sendChat(Chatter.of(user), target.get(), format, null, event.getMessage().getContentDisplay().replace('ยง', '&').replace('\n', ' ')); - event.getMessage().delete().queue(); } } diff --git a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java index 9bcc2869..64f871b4 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java +++ b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java @@ -18,6 +18,7 @@ package de.steamwar.velocitycore.discord.listeners; +import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.channels.DiscordChannel; import de.steamwar.velocitycore.discord.channels.InteractionReply; @@ -35,6 +36,7 @@ import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; public class ChannelListener extends ListenerAdapter { @Getter @@ -71,6 +73,7 @@ public class ChannelListener extends ListenerAdapter { if(sender.user().getDiscordId() == null) 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)) diff --git a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java index 8956683a..921eba94 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java +++ b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java @@ -19,14 +19,15 @@ package de.steamwar.velocitycore.discord.listeners; -import de.steamwar.velocitycore.discord.DiscordBot; -import de.steamwar.velocitycore.discord.DiscordTicketType; -import de.steamwar.velocitycore.discord.channels.DiscordChannel; -import de.steamwar.velocitycore.discord.channels.InteractionReply; import de.steamwar.messages.Chatter; import de.steamwar.messages.ChatterGroup; import de.steamwar.messages.Message; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; +import de.steamwar.velocitycore.discord.DiscordBot; +import de.steamwar.velocitycore.discord.DiscordTicketType; +import de.steamwar.velocitycore.discord.channels.DiscordChannel; +import de.steamwar.velocitycore.discord.channels.InteractionReply; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; @@ -150,7 +151,9 @@ public class DiscordTicketHandler extends ListenerAdapter { ChatterGroup receivers = Chatter.serverteam(); try { - receivers = new ChatterGroup(receivers, Chatter.of(SteamwarUser.get(Long.parseLong(channel.getTopic())))); + SteamwarUser user = SteamwarUser.get(Long.parseLong(channel.getTopic())); + if(!user.perms().contains(UserPerm.TEAM)) + receivers = new ChatterGroup(receivers, Chatter.of(user)); } catch(NumberFormatException e) { //ignored }