Skip to content

Commit

Permalink
Only allow specific bot devs to run ?eval as mods can just give thems…
Browse files Browse the repository at this point in the history
…elves the role.
  • Loading branch information
Reasonlesss committed May 3, 2024
1 parent 8783ab4 commit d1ded70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@
import javax.script.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;


public class EvalCommand extends Command {

// Moderators can just give themselves bot dev role apparently...
private static final Set<Long> BOT_DEVELOPERS = Set.of(
511653192942092289L, // Reasonless
248855041803288576L, // Tomoli75
945012492030074900L // Owen1212055
);

private static final List<String> IMPORTS = List.of(
"net.dv8tion.jda.core",
"net.dv8tion.jda.core.managers",
Expand Down Expand Up @@ -68,6 +76,17 @@ public void run(CommandEvent event) {
return;
}

boolean hasManual = BOT_DEVELOPERS.contains(event.getMember().getIdLong());
boolean hasRole = Permission.DEVELOPER.hasPermission(event.getMember());
if (!hasManual && !hasRole) {
EmbedBuilder builder = new EmbedBuilder();
builder.setTitle("No.");
builder.setColor(Color.red);

event.getChannel().sendMessageEmbeds(builder.build()).queue();
return;
}


ScriptEngine engine = new ScriptEngineManager().getEngineByName("groovy");
engine.put("jda", event.getJDA());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.util.stream.Collectors;

public enum Permission {
BOT_DEVELOPER(999),
DEVELOPER(999),
BOT_DEVELOPER(998),
// Ask DragonSlasher, not me.
ADMINISTRATOR(666),
MODERATION(5),
Expand Down

0 comments on commit d1ded70

Please sign in to comment.