From 04c4533c40d016e7e3f7dcb98f33491c46b52ba7 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 6 Jul 2024 20:08:26 +0100 Subject: [PATCH] update command log --- .../cc/fascinated/bat/service/CommandService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index f40a88b..ae04281 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -16,6 +16,7 @@ import lombok.extern.log4j.Log4j2; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.commands.Command; @@ -229,8 +230,14 @@ public class CommandService extends ListenerAdapter { // Execute the command try { - command.execute(guild, user, event.getChannel(), event.getMember(), event.getInteraction()); - log.info("Executed command \"{}\" for user \"{}\" (took: {}ms)", command.getInfo().getName(), user.getName(), System.currentTimeMillis() - before); + MessageChannelUnion channel = event.getChannel(); + command.execute(guild, user, channel, event.getMember(), event.getInteraction()); + log.info("Executed command \"{}\" for user \"{}\" in channel \"{}\" (took: {}ms)", + command.getInfo().getName(), + user.getName(), + channel.getName(), + System.currentTimeMillis() - before + ); } catch (Exception ex) { log.error("An error occurred while executing command \"{}\"", command.getInfo().getName(), ex); event.replyEmbeds(EmbedUtils.genericInteractionError(ex).build()).setEphemeral(true).queue();