MCPcopy Create free account
hub / github.com/RTByte/rtbyte / run

Method run

src/commands/User/help.js:27–67  ·  view source on GitHub ↗
(msg, [command])

Source from the content-addressed store, hash-verified

25 }
26
27 async run(msg, [command]) {
28 if (command) {
29 const prefix = msg.guild ? msg.guild.settings.get('prefix') : this.client.options.prefix;
30 const embed = new MessageEmbed()
31 .setAuthor(`${prefix}${command.name}`, this.client.user.displayAvatarURL())
32 .setDescription(isFunction(command.description) ? command.description(msg.language) : command.description)
33 .addField(msg.language.get('COMMAND_HELP_USAGE'), command.usage.fullUsage(msg))
34 .addField(msg.language.get('COMMAND_HELP_EXTENDED'), isFunction(command.extendedHelp) ? command.extendedHelp(msg.language) : command.extendedHelp)
35 .setColor(this.client.settings.get('colors.white'))
36 .setThumbnail(this.client.user.displayAvatarURL(), 50, 50)
37 .setTimestamp()
38 .setFooter(msg.language.get('COMMAND_REQUESTED_BY', msg), msg.author.displayAvatarURL());
39
40 return msg.send('', { disableEveryone: true, embed: embed });
41 }
42
43 if (!('all' in msg.flags) && msg.guild && msg.channel.permissionsFor(this.client.user).has(PERMISSIONS_RICHDISPLAY)) {
44 // Finish the previous handler
45 const previousHandler = this.handlers.get(msg.author.id);
46 if (previousHandler) previousHandler.stop();
47
48 const loadingEmbed = new MessageEmbed()
49 .setAuthor(msg.language.get('COMMAND_HELP_EMBEDTITLE'), this.client.user.displayAvatarURL())
50 .setDescription(msg.language.get('COMMAND_HELP_LOADING'))
51 .setColor(this.client.settings.get('colors.white'))
52 .setThumbnail(this.client.user.displayAvatarURL(), 50, 50)
53 .setTimestamp();
54
55 const handler = await (await this.buildDisplay(msg)).run(await msg.send('', { disableEveryone: true, embed: loadingEmbed }), {
56 filter: (reaction, user) => user.id === msg.author.id,
57 time
58 });
59 handler.on('end', () => this.handlers.delete(msg.author.id));
60 this.handlers.set(msg.author.id, handler);
61 return handler;
62 }
63
64 return msg.author.send(await this.buildHelp(msg), { split: { char: '\n' } })
65 .then(() => { if (msg.channel.type !== 'dm') msg.sendMessage(msg.language.get('COMMAND_HELP_DM')); })
66 .catch(() => { if (msg.channel.type !== 'dm') msg.sendMessage(msg.language.get('COMMAND_HELP_NODM')); });
67 }
68
69 async buildHelp(msg) {
70 const commands = await this._fetchCommands(msg);

Callers 1

constructorMethod · 0.45

Calls 5

sendMethod · 0.80
buildHelpMethod · 0.80
buildDisplayMethod · 0.45
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected