forked from Galactic/galactic-bot
embedUsage
This commit is contained in:
parent
9229eedd29
commit
bbd8a390c4
@ -1,4 +1,5 @@
|
||||
const Component = require('./Component.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
class Command extends Component {
|
||||
|
||||
@ -54,6 +55,42 @@ class Command extends Component {
|
||||
return `${this.module.id}:${this.id}`;
|
||||
}
|
||||
|
||||
usageEmbed(message, verbose = false) {
|
||||
|
||||
const { guild } = message;
|
||||
const prefix = guild?.prefix || this.client.prefix;
|
||||
const fields = [];
|
||||
|
||||
if (this.examples.length) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_EXAMPLES')}`,
|
||||
value: this.examples.map((e) => this.rawExamples ? `\`${prefix}${e}\`` : `\`${prefix}${this.name} ${e}\``).join('\n')
|
||||
});
|
||||
}
|
||||
if (this.aliases.length && verbose) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_ALIASES')}`,
|
||||
value: this.aliases.join(', ')
|
||||
});
|
||||
}
|
||||
if (this.arguments.length && verbose) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_ARGUMENTS')}`,
|
||||
value: this.arguments.map((a) => `\`${a.types.length === 1 && a.types.includes('FLAG') ? '--' : ''}${a.name}${a.usage ? ` ${a.usage}` : ''}\`: ${message.format(`A_${a.name.toUpperCase()}_${this.name.toUpperCase()}_DESCRIPTION`)}`)
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
author: {
|
||||
name: `${this.name}${this.module ? ` (${this.module.resolveable})` : ''}`
|
||||
},
|
||||
description: stripIndents`\`${prefix}${this.name}${this.usage ? ` ${this.usage}` : ''}\`${this.guildOnly ? ' *(guild-only)*' : ''}
|
||||
${message.format(this.description)}`,
|
||||
fields
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Command;
|
@ -20,6 +20,7 @@ class Setting extends Component {
|
||||
|
||||
this.description = opts.description || `S_${opts.name.toUpperCase()}_DESCRIPTION`;
|
||||
this.examples = opts.examples || [];
|
||||
this.rawExamples = Boolean(opts.rawExamples);
|
||||
this.usage = opts.usage || '';
|
||||
this.archivable = opts.archivable === undefined ? true : Boolean(opts.archivable);
|
||||
|
||||
@ -92,6 +93,42 @@ class Setting extends Component {
|
||||
get display() {
|
||||
return this.name.toLowerCase();
|
||||
}
|
||||
|
||||
usageEmbed(message, verbose = false) {
|
||||
|
||||
const { guild } = message;
|
||||
const prefix = guild?.prefix || this.client.prefix;
|
||||
const fields = [];
|
||||
|
||||
if (this.examples.length) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_EXAMPLES')}`,
|
||||
value: this.examples.map((e) => this.rawExamples ? `\`${prefix}${e}\`` : `\`${prefix}${this.name} ${e}\``).join('\n')
|
||||
});
|
||||
}
|
||||
if (this.aliases.length && verbose) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_ALIASES')}`,
|
||||
value: this.aliases.join(', ')
|
||||
});
|
||||
}
|
||||
if (this.arguments.length && verbose) {
|
||||
fields.push({
|
||||
name: `》${message.format('GENERAL_ARGUMENTS')}`,
|
||||
value: this.arguments.map((a) => `\`${a.types.length === 1 && a.types.includes('FLAG') ? '--' : ''}${a.name}${a.usage ? ` ${a.usage}` : ''}\`: ${message.format(`A_${a.name.toUpperCase()}_${this.name.toUpperCase()}_DESCRIPTION`)}`)
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
author: {
|
||||
name: `${this.name}${this.module ? ` (${this.module.resolveable})` : ''}`
|
||||
},
|
||||
description: stripIndents`\`${prefix}${this.name}${this.usage ? ` ${this.usage}` : ''}\`${this.guildOnly ? ' *(guild-only)*' : ''}
|
||||
${message.format(this.description)}`,
|
||||
fields
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user