From 5d9d5de237df66caea8b5ba0ead44f8cc8f6399c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 28 Jun 2024 10:41:23 +0200 Subject: [PATCH] Fix DiscordCommands Signed-off-by: Lixfel --- .../velocitycore/discord/listeners/ChannelListener.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java index 64f871b4..115be4fe 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java +++ b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java @@ -18,12 +18,12 @@ package de.steamwar.velocitycore.discord.listeners; +import de.steamwar.command.SWCommand; +import de.steamwar.sql.UserPerm; 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; -import de.steamwar.command.SWCommand; -import de.steamwar.sql.UserPerm; import lombok.Getter; import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.entities.MessageChannel; @@ -32,10 +32,12 @@ import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.InteractionType; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.logging.Level; public class ChannelListener extends ListenerAdapter { @@ -79,7 +81,7 @@ public class ChannelListener extends ListenerAdapter { if(permission != null && !sender.user().perms().contains(permission)) return; - command.execute(sender, event.getOption(DiscordBot.ARGUMENT_NAME).getAsString().split(" ")); + command.execute(sender, Optional.ofNullable(event.getOption(DiscordBot.ARGUMENT_NAME)).map(OptionMapping::getAsString).orElse("").split(" ")); }); } }