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

Method buildDisplay

src/commands/User/help.js:81–125  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

79 }
80
81 async buildDisplay(msg) {
82 const arrowToLeftEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.arrowToLeft'));
83 const arrowLeftEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.arrowLeft'));
84 const arrowRightEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.arrowRight'));
85 const arrowToRightEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.arrowToRight'));
86 const rejectEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.reject'));
87 const listEmoji = this.client.emojis.cache.get(this.client.settings.get('emoji.list'));
88 const commands = await this._fetchCommands(msg);
89 const prefix = msg.guild ? msg.guild.settings.get('prefix') : this.client.options.prefix;
90 const display = new RichDisplay()
91 .setEmojis({
92 first: arrowToLeftEmoji.id,
93 back: arrowLeftEmoji.id,
94 forward: arrowRightEmoji.id,
95 last: arrowToRightEmoji.id,
96 stop: rejectEmoji.id,
97 jump: listEmoji.id
98 })
99 .setFooterPrefix(`${msg.language.get('COMMAND_REQUESTED_BY', msg)} (`)
100 .setFooterSuffix(')');
101 for (const [category, list] of commands) {
102 display.addPage(new MessageEmbed()
103 .setAuthor(msg.language.get('COMMAND_HELP_EMBEDTITLE'), this.client.user.displayAvatarURL())
104 .setTitle(`${category} ${msg.language.get('COMMAND_HELP_COMMANDS')}`)
105 .setColor(this.client.settings.get('colors.white'))
106 .setThumbnail(this.client.user.displayAvatarURL(), 50, 50)
107 .setTimestamp()
108 .setDescription(list.map(this.formatCommand.bind(this, msg, prefix, true)).join('\n'))
109 );
110 }
111
112 if (!msg.guild.settings.get('commands.customCommandsEnabled') || !msg.guild.settings.get('commands.customCommands').length) return display;
113 const names = msg.guild.settings.get('commands.customCommands').map(cmd => cmd.name.toLowerCase());
114
115 display.addPage(new MessageEmbed()
116 .setAuthor(msg.language.get('COMMAND_HELP_EMBEDTITLE'), this.client.user.displayAvatarURL())
117 .setTitle(msg.language.get('CUSTOM_COMMANDS'))
118 .setColor(this.client.settings.get('colors.white'))
119 .setThumbnail(this.client.user.displayAvatarURL(), 50, 50)
120 .setTimestamp()
121 .setDescription(names.map(name => `• **${name}**`))
122 );
123
124 return display;
125 }
126
127 formatCommand(msg, prefix, richDisplay, command) {
128 const description = isFunction(command.description) ? command.description(msg.language) : command.description;

Callers 1

runMethod · 0.45

Calls 2

_fetchCommandsMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected