-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from aternosorg/help
refactor help command, remove legacy commands
- Loading branch information
Showing
10 changed files
with
115 additions
and
226 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const Command = require('../../Command'); | ||
const {MessageEmbed} = require('discord.js'); | ||
const util = require('../../util'); | ||
|
||
class HelpCommand extends Command { | ||
|
||
static description = 'View command information'; | ||
|
||
static usage = '[<category|command>]'; | ||
|
||
static names = ['help']; | ||
|
||
async execute() { | ||
|
||
const commandManager = require('../../features/message/CommandManager'); | ||
|
||
const categories = commandManager.getCategories(); | ||
const commands = commandManager.getCommands(); | ||
|
||
if (!this.args.length) { | ||
const embed = new MessageEmbed() | ||
.setColor(util.color.red) | ||
.setFooter(`View a command or category using ${this.prefix}help <category|command>`); | ||
for (const [key, commands] of categories.entries()) { | ||
if (commands.length === 0) continue; | ||
embed.addField(util.toTitleCase(key), commands.map(c => c.names).flat().sort().join(', ')); | ||
} | ||
return this.message.channel.send(embed); | ||
} | ||
|
||
const name = this.args.shift().toLowerCase(); | ||
const category = categories.get(name); | ||
const command = commands.get(name); | ||
if (!category && !command) return this.sendUsage(); | ||
|
||
if (category) { | ||
let description = ''; | ||
|
||
for (const command of category) { | ||
description += command.getOverview() + '\n'; | ||
} | ||
|
||
return this.message.channel.send(new MessageEmbed() | ||
.setTitle(`ModBot ${util.toTitleCase(name)} Commands:`) | ||
.setColor(util.color.red) | ||
.setDescription(description) | ||
.setFooter(`View a command using ${this.prefix}help <command>`) | ||
); | ||
} | ||
|
||
if (command) return this.message.channel.send(await command.getUsage(this.message, name, this.guildConfig)); | ||
} | ||
} | ||
|
||
module.exports = HelpCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.