Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
Testing new help command output
Browse files Browse the repository at this point in the history
  • Loading branch information
Em1tt committed May 12, 2021
1 parent 4b40cc0 commit 74f6886
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/modules/discord/cmd/bash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const prop = {
name : "bash",
desc : "Execute a bash command.",
usage : "bash [command] [...args]",
category: "Server",
category: "developer",

run: async (bot: Client, msg: Message, args: Array<string>): Promise<void> => {
if (!config.discord.dev.includes(msg.author.id)) return;
Expand Down
22 changes: 17 additions & 5 deletions src/modules/discord/cmd/help.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
// help command
import { Client, Message, Collection } from "discord.js";
import { Client, Message, Collection, MessageEmbed } from "discord.js";
import { Command } from "../../../types/discord/command";
import config from "../../../config.json";

export const prop = {
name : "help",
desc : "See help on some command.",
usage : "help [command]",
category: "Bot",
category: "user",

run: (bot : Client,
msg : Message,
args: Array<string>,
cmds: Collection<string, Command>): void => {
// display all commands
if (args.length == 0) {
const names = [];
cmds.forEach(c => names.push("`" + c.prop.name + "`"));
msg.reply(`All commands: ${names.join(", ")}`);
const categories = [];
cmds.forEach(cmd => {
if(!categories.includes(cmd.prop.category)){
categories.push(cmd.prop.category);
}
})
const helpEmbed = new MessageEmbed()
.setTitle("Help command")
.setColor("RANDOM")
.setDescription(`My prefix is ${config.discord.prefix}. Do \`${config.discord.prefix}help <command>\` to get detailed help for a certain command.\n\n`);
categories.forEach(cat=>{
helpEmbed.description += `**${cat}**: ${cmds.filter(cmd => cmd.prop.category == cat).map(c => `${c.prop.name} `)}\n`;
});
msg.channel.send(helpEmbed);
} else {
const cmd: Command = cmds.get(args[0]);
msg.reply(`**${cmd.prop.name}**\n${cmd.prop.desc}\n\nCategory: **${cmd.prop.category}**\nUsage: \`${cmd.prop.usage}\``);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/discord/cmd/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const prop = {
name : "ping",
desc : "Check if the bot is alive.",
usage : "ping",
category: "Bot",
category: "bot",

run: (bot: Client,
msg: Message): void => { msg.reply("Pong!") }
Expand Down

0 comments on commit 74f6886

Please sign in to comment.