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

Method run

commands/general/prefix.js:5–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4class PrefixCommand extends Command {
5 async run() {
6 if (!this.guild)
7 return this.getString("commands.responses.prefix.current", {
8 params: {
9 prefix: process.env.PREFIX ?? "&",
10 },
11 });
12 const guild = await this.database?.getGuild(this.guild.id);
13 if (this.args.length !== 0) {
14 if (!this.database) {
15 return this.getString("commands.responses.prefix.stateless");
16 }
17 const owners = process.env.OWNER?.split(",") ?? [];
18 if (!this.memberPermissions.has("ADMINISTRATOR") && !owners.includes(this.author.id)) {
19 this.success = false;
20 return this.getString("commands.responses.prefix.adminOnly");
21 }
22 await this.database.setPrefix(this.args[0], this.guild.id);
23 return this.getString("commands.responses.prefix.changed", {
24 params: {
25 prefix: this.args[0],
26 },
27 });
28 }
29 return this.getString("commands.responses.prefix.current", {
30 params: {
31 prefix: guild?.prefix ?? process.env.PREFIX ?? "&",
32 },
33 });
34 }
35
36 static description = "Checks/changes the server prefix";
37 static aliases = ["setprefix", "changeprefix", "checkprefix"];

Callers

nothing calls this directly

Calls 3

getStringMethod · 0.80
getGuildMethod · 0.45
setPrefixMethod · 0.45

Tested by

no test coverage detected