1 |
const { MessageActionRow, MessageButton } = require("discord.js"); |
import { CommandHelpData } from "../types/CommandHelpData"; |
|
const MessageEmbed = require("../src/MessageEmbed"); |
|
|
const { escapeRegex } = require("../src/util"); |
|
2 |
|
|
3 |
module.exports = { |
export default { |
4 |
version: "1.10.0", |
version: "2.0.0-beta1", |
5 |
commands: [ |
commands: <CommandHelpData[]> [ |
6 |
{ |
{ |
7 |
name: 'about', |
name: 'about', |
8 |
shortBrief: "Show information about the bot.", |
shortBrief: "Show information about the bot.", |
406 |
example: "`%%warnings`\n`%%warnings 948489127957979253978538`", |
example: "`%%warnings`\n`%%warnings 948489127957979253978538`", |
407 |
notes: null |
notes: null |
408 |
}, |
}, |
|
], |
|
|
async render() { |
|
|
let string = ''; |
|
|
|
|
|
for (let cmd of this.commands) { |
|
|
string += `\n\n**${cmd.name}**\n${cmd.shortBrief}`; |
|
|
} |
|
|
|
|
|
return string; |
|
|
}, |
|
|
async handle(msg, cm) { |
|
|
if (typeof cm.args[0] === 'undefined') { |
|
|
await msg.reply({ |
|
|
embeds: [ |
|
|
new MessageEmbed() |
|
|
.setDescription("The command list.\n\n`<...>` means required argument, `[...]` means optional argument.\n\nRun `" + app.config.get('prefix') + "help <commandName>` for more information about a specific command.\n" + await this.render()) |
|
|
.setTitle('Help') |
|
|
], |
|
|
}); |
|
|
|
|
|
return; |
|
|
} |
|
|
|
|
|
const cmd = this.commands.find(c => c.name === cm.args[0]); |
|
|
|
|
|
if (!cmd) { |
|
|
await msg.reply({ |
|
|
embeds: [ |
|
|
new MessageEmbed() |
|
|
.setColor('#f14a60') |
|
|
.setDescription(`Invalid command \`${cm.args[0]}\`.`) |
|
|
] |
|
|
}); |
|
|
|
|
|
return; |
|
|
} |
|
|
|
|
|
let fields = [ |
|
|
{ |
|
|
name: "Usage", |
|
|
value: `\`${app.config.get('prefix')}${cmd.name}\`` + (cmd.structure.trim() !== '' ? ` \`${cmd.structure}\`` : '') |
|
|
}, |
|
|
{ |
|
|
name: 'Examples', |
|
|
value: cmd.example.replace(/\%\%/g, app.config.get('prefix')) |
|
|
} |
|
|
]; |
|
|
|
|
|
if (cmd.options !== undefined) { |
|
|
let str = ''; |
|
|
|
|
|
for (let opt in cmd.options) |
|
|
str += `\`${opt}\` - ${cmd.options[opt]}\n`; |
|
|
|
|
|
str = str.substring(0, str.length - 1); |
|
|
|
|
|
fields.push({ |
|
|
name: 'Options', |
|
|
value: str |
|
|
}); |
|
|
} |
|
|
|
|
|
if (cmd.notes !== null) { |
|
|
fields.push({ |
|
|
name: "Notes", |
|
|
value: cmd.notes |
|
|
}); |
|
|
} |
|
|
|
|
|
await msg.reply({ |
|
|
embeds: [ |
|
|
new MessageEmbed() |
|
|
.setTitle(`${app.config.get('prefix')}${cmd.name}`) |
|
|
.setDescription("`<...>` means required argument, `[...]` means optional argument.\n\n" + (cmd.description !== null ? cmd.description : cmd.shortBrief)) |
|
|
.addFields(fields) |
|
|
] |
|
|
}); |
|
|
} |
|
|
}; |
|
409 |
|
] |
410 |
|
} |