[BUG] Have linked commands sent feedback when executed

This commit is contained in:
2023-10-28 14:35:35 +02:00
parent ade2e95790
commit 6fa38f444c
3 changed files with 8 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
version_major=0
version_minor=0
version_patch=29
version_patch=30
shade_group=com.hypherionmc.sdlink.shaded.

View File

@@ -6,6 +6,7 @@ package com.hypherionmc.sdlink.core.discord.hooks;
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
import com.hypherionmc.sdlink.core.database.SDLinkAccount;
import com.hypherionmc.sdlink.core.messaging.Result;
import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
import net.dv8tion.jda.api.entities.ISnowflake;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@@ -13,6 +14,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.hypherionmc.sdlink.core.managers.DatabaseManager.sdlinkDatabase;
@@ -40,9 +42,11 @@ public class MinecraftCommandHook {
String raw = event.getMessage().getContentRaw().substring(SDLinkConfig.INSTANCE.linkedCommands.prefix.length());
if (commands.stream().anyMatch(raw::startsWith)) {
SDLinkPlatform.minecraftHelper.executeMinecraftCommand(raw, Integer.MAX_VALUE, event, account.orElse(null));
Result res = SDLinkPlatform.minecraftHelper.executeMinecraftCommand(raw, Integer.MAX_VALUE, event, account.orElse(null));
event.getMessage().reply(res.getMessage()).mentionRepliedUser(false).queue(s -> s.delete().queueAfter(5, TimeUnit.SECONDS));
} else {
SDLinkPlatform.minecraftHelper.executeMinecraftCommand(raw, permLevel, event, account.orElse(null));
Result res = SDLinkPlatform.minecraftHelper.executeMinecraftCommand(raw, permLevel, event, account.orElse(null));
event.getMessage().reply(res.getMessage()).mentionRepliedUser(false).queue(s -> s.delete().queueAfter(5, TimeUnit.SECONDS));
}
}
}

View File

@@ -27,7 +27,7 @@ public interface IMinecraftHelper {
List<MinecraftAccount> getOnlinePlayers();
long getServerUptime();
String getServerVersion();
void executeMinecraftCommand(String command, int permLevel, MessageReceivedEvent event, @Nullable SDLinkAccount account);
Result executeMinecraftCommand(String command, int permLevel, MessageReceivedEvent event, @Nullable SDLinkAccount account);
boolean isOnlineMode();
void banPlayer(MinecraftAccount acc);
}