MCPcopy Create free account
hub / github.com/esmBot/esmBot / run

Method run

commands/general/command/disable.js:5–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4class CommandDisableCommand extends Command {
5 async run() {
6 this.success = false;
7 if (!this.guild) return this.getString("guildOnly");
8 if (!this.database) return this.getString("noDatabase");
9 const owners = process.env.OWNER?.split(",") ?? [];
10 if (!this.memberPermissions.has("ADMINISTRATOR") && !owners.includes(this.author.id))
11 return this.getString("commands.responses.command.adminOnly");
12
13 const commandName = this.getOptionString("cmd", true)?.toLowerCase();
14 if (!commandName) return this.getString("commands.responses.command.noInput");
15 if (!commands.has(commandName.split(" ")[0]) && !aliases.has(commandName))
16 return this.getString("commands.responses.command.invalidCmd");
17
18 const guildDB = await this.database.getGuild(this.guild.id);
19 const command = aliases.get(commandName) ?? commandName;
20
21 if (command === "command") return this.getString("commands.responses.command.cannotDisable");
22 if (guildDB.disabled_commands.includes(command))
23 return this.getString("commands.responses.command.alreadyDisabled");
24
25 await this.database.disableCommand(this.guild.id, command);
26 this.success = true;
27 return this.getString("commands.responses.command.disabled", {
28 params: {
29 command,
30 prefix: guildDB.prefix,
31 },
32 });
33 }
34
35 static description = "Disables a classic command";
36 static flags = [

Callers

nothing calls this directly

Calls 4

getStringMethod · 0.80
getOptionStringMethod · 0.80
getGuildMethod · 0.45
disableCommandMethod · 0.45

Tested by

no test coverage detected