[FEAT] Use Discord Name for executed commands
This commit is contained in:
@@ -11,6 +11,7 @@ import com.hypherionmc.sdlink.core.managers.RoleManager;
|
|||||||
import com.hypherionmc.sdlink.core.messaging.Result;
|
import com.hypherionmc.sdlink.core.messaging.Result;
|
||||||
import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
|
import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
|
||||||
import com.jagrosh.jdautilities.command.SlashCommandEvent;
|
import com.jagrosh.jdautilities.command.SlashCommandEvent;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
@@ -69,12 +70,12 @@ public class MCSlashCommand extends SDLinkSlashCommand {
|
|||||||
|
|
||||||
boolean userRole = role != null && event.getMember().getRoles().stream().anyMatch(r -> r.getIdLong() == role.getIdLong());
|
boolean userRole = role != null && event.getMember().getRoles().stream().anyMatch(r -> r.getIdLong() == role.getIdLong());
|
||||||
if (userRole) {
|
if (userRole) {
|
||||||
executeCommand(event, command, args.toString());
|
executeCommand(event, command, args.toString(), event.getMember());
|
||||||
} else {
|
} else {
|
||||||
event.reply("You need the " + role.getName() + " role to perform this action").setEphemeral(true).queue();
|
event.reply("You need the " + role.getName() + " role to perform this action").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
executeCommand(event, command, args.toString());
|
executeCommand(event, command, args.toString(), event.getMember());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,8 +88,8 @@ public class MCSlashCommand extends SDLinkSlashCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeCommand(SlashCommandEvent event, LinkedCommandsConfig.Command mcCommand, String args) {
|
private void executeCommand(SlashCommandEvent event, LinkedCommandsConfig.Command mcCommand, String args, Member member) {
|
||||||
Result result = SDLinkPlatform.minecraftHelper.executeMinecraftCommand(mcCommand.mcCommand, args);
|
Result result = SDLinkPlatform.minecraftHelper.executeMinecraftCommand(mcCommand.mcCommand, args, member);
|
||||||
event.reply(result.getMessage()).setEphemeral(true).queue();
|
event.reply(result.getMessage()).setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ public interface IMinecraftHelper {
|
|||||||
List<MinecraftAccount> getOnlinePlayers();
|
List<MinecraftAccount> getOnlinePlayers();
|
||||||
long getServerUptime();
|
long getServerUptime();
|
||||||
String getServerVersion();
|
String getServerVersion();
|
||||||
Result executeMinecraftCommand(String command, String args);
|
Result executeMinecraftCommand(String command, String args, Member member);
|
||||||
boolean isOnlineMode();
|
boolean isOnlineMode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user