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

Method run

commands/general/channel/disable.js:6–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5class ChannelDisableCommand extends Command {
6 async run() {
7 this.success = false;
8 if (!this.guild) return this.getString("guildOnly");
9 if (!this.database) return this.getString("noDatabase");
10 if (!this.channel) throw Error("No channel found");
11 const owners = process.env.OWNER?.split(",") ?? [];
12 if (!this.memberPermissions.has("ADMINISTRATOR") && !owners.includes(this.author.id))
13 return this.getString("commands.responses.channel.adminOnly");
14
15 const channelId = this.getOptionString("channel", true);
16 const guildDB = await this.database.getGuild(this.guild.id);
17
18 let channel;
19 if (channelId?.match(/^<?[@#]?[&!]?\d+>?$/) && safeBigInt(channelId) >= 21154535154122752n) {
20 const id = channelId
21 .replaceAll("@", "")
22 .replaceAll("#", "")
23 .replaceAll("!", "")
24 .replaceAll("&", "")
25 .replaceAll("<", "")
26 .replaceAll(">", "");
27 if (guildDB.disabled.includes(id)) return this.getString("commands.responses.channel.alreadyDisabled");
28 channel = this.guild.channels.get(id) ?? (await this.client.rest.channels.get(id));
29 } else {
30 if (guildDB.disabled.includes(this.channel.id))
31 return this.getString("commands.responses.channel.alreadyDisabled");
32 channel = this.channel;
33 }
34 if (!(channel instanceof GuildChannel) || channel.guildID !== this.guild.id)
35 return this.getString("commands.responses.channel.notInServer");
36
37 await this.database.disableChannel(channel.id, channel.guildID);
38 this.success = true;
39 return this.getString("commands.responses.channel.disabled", {
40 params: {
41 prefix: guildDB.prefix,
42 },
43 });
44 }
45
46 static description = "Disables classic commands in a channel";
47 static flags = [

Callers

nothing calls this directly

Calls 5

safeBigIntFunction · 0.85
getStringMethod · 0.80
getOptionStringMethod · 0.80
getGuildMethod · 0.45
disableChannelMethod · 0.45

Tested by

no test coverage detected