implement canExecDevCommands todo for eval

pull/3/head
Matthew 2024-11-17 00:58:09 -05:00
parent fdaeeec513
commit ba6c9218c1
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
1 changed files with 9 additions and 5 deletions

View File

@ -2,10 +2,11 @@ import DiscordInteractionCommand from "../../util/DiscordInteractionCommand";
import { ChatInputCommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } from "discord.js";
import { inspect } from "util"; import { inspect } from "util";
import { discordBotToken } from "../../config.json"; import { discordBotToken } from "../../config.json";
import { PartnerModel } from "../../database/Partner";
export default class Eval extends DiscordInteractionCommand { export default class Eval extends DiscordInteractionCommand {
// This is a list of IDs that are allowed to use this command. // This is a list of IDs that are allowed to use this command.
private listOfAllowedIDs: string[]; private listOfAllowedIDs: string[] = [];
constructor() { constructor() {
super("eval", "Executes arbitrary JS code and returns the output."); super("eval", "Executes arbitrary JS code and returns the output.");
@ -25,10 +26,13 @@ export default class Eval extends DiscordInteractionCommand {
option.setName("depth").setDescription("The depth of the inspection.").setRequired(false) option.setName("depth").setDescription("The depth of the inspection.").setRequired(false)
); );
// TODO: replace with database entry "canExecuteDevCommands" // this checks against the database and adds all of the partners that are "allowed to perform dev commands"
this.listOfAllowedIDs = [ // doing the database check in the initialization prevents us from having to check the database every time this command is ran
"278620217221971968", // Matthew PartnerModel.find({ canPerformDevCommands: true }).then((partners) => {
]; for (const partner of partners) {
this.listOfAllowedIDs.push(partner.discordID as string);
}
});
} }
public async execute(interaction: ChatInputCommandInteraction) { public async execute(interaction: ChatInputCommandInteraction) {