Skip to content

Commit

Permalink
Do not restrict the status command
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jun 11, 2022
1 parent 1ffc720 commit fab6e1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public abstract class RLCommand extends SlashCommand {

protected final Supplier<BaseProcessManager> processManager;
protected final List<String> roles;
protected boolean isRestricted = true;

protected RLCommand(final Supplier<BaseProcessManager> processManager, final Config.Discord config) {
this.processManager = processManager;
Expand All @@ -41,7 +42,7 @@ protected RLCommand(final Supplier<BaseProcessManager> processManager, final Con

@Override
protected final void execute(final SlashCommandEvent event) {
if (event.getMember() != null || event.getMember().getRoles().stream().noneMatch(role -> roles.contains(role.getId()))) {
if (isRestricted && (event.getMember() == null || event.getMember().getRoles().stream().noneMatch(role -> roles.contains(role.getId())))) {
event.deferReply(true).setContent("You do not have the required permissions to run this command.").queue();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public StatusCommand(final Supplier<BaseProcessManager> jarUpdater, final Config
super(jarUpdater, config);
name = "status";
help = "Gets information about the process status.";
isRestricted = false;
}

@Override
Expand All @@ -74,7 +75,7 @@ protected void exec(final SlashCommandEvent event) {
final var embed = new EmbedBuilder()
.setColor(Color.GREEN)
.setTitle("Process is running.")
.addField("Jar Version", version.orElse("Unknown"), true)
.addField("Process Version", version.orElse("Unknown"), true)
.addField("Launcher Version", Main.VERSION, true)
.addField("Running Since", process.process().info().startInstant().map(TimeFormat.RELATIVE::format).orElse("Unknown startup time"), true)
.setTimestamp(Instant.now());
Expand Down Expand Up @@ -178,8 +179,9 @@ public String buildThreadInfo(final ThreadInfo thread) {
}

public boolean isEnabled(final String roleId) {
for (var r : enabledRoles) {
if (r.equals(roleId)) return true;
for (var r : roles) {
if (r.equals(roleId))
return true;
}
return false;
}
Expand Down

0 comments on commit fab6e1f

Please sign in to comment.