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

Method run

commands/general/help.js:9–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8class HelpCommand extends Command {
9 async run() {
10 if (!this.permissions.has("EMBED_LINKS")) {
11 this.success = false;
12 return this.getString("permissions.noEmbedLinks");
13 }
14 let prefix;
15 if (this.guild && this.database) {
16 prefix = (await this.database.getGuild(this.guild.id)).prefix;
17 } else {
18 prefix = process.env.PREFIX ?? "&";
19 }
20 if (
21 this.args.length !== 0 &&
22 (collections.commands.has(this.args[0].toLowerCase()) || collections.aliases.has(this.args[0].toLowerCase()))
23 ) {
24 const joined = this.args.join(" ").toLowerCase();
25 const command = collections.aliases.get(joined) ?? joined;
26 const info = collections.commands.get(command);
27 if (!info) return this.getString("commands.responses.help.noInfo");
28 const params = info.params.filter((v) => typeof v === "string");
29 const embed = {
30 embeds: [
31 {
32 author: {
33 name: this.getString("commands.responses.help.header"),
34 iconURL: this.client.user.avatarURL(),
35 },
36 title: `${this.guild ? prefix : ""}${command}`,
37 url: "https://esmbot.net/help.html",
38 description: info.description,
39 color: 0xff0000,
40 fields: [
41 {
42 name: this.getString("commands.responses.help.aliases"),
43 value:
44 info.aliases.length !== 0 ? info.aliases.join(", ") : this.getString("commands.responses.help.none"),
45 },
46 {
47 name: this.getString("commands.responses.help.parameters"),
48 value:
49 command === "tags"
50 ? `[${this.getString("commands.responses.help.name")}]`
51 : params
52 ? params.length !== 0
53 ? params.join(" ")
54 : this.getString("commands.responses.help.none")
55 : this.getString("commands.responses.help.none"),
56 inline: true,
57 },
58 ],
59 },
60 ],
61 };
62 if (this.database) {
63 const counts = await this.database.getCounts();
64 const value = counts.get(command);
65 if (value) {
66 embed.embeds[0].fields.push({

Callers

nothing calls this directly

Calls 4

convFlagTypeFunction · 0.85
getStringMethod · 0.80
getGuildMethod · 0.45
getCountsMethod · 0.45

Tested by

no test coverage detected