From 88acd94d101fa6f0ec0b9fa97f175b6f56bb61f6 Mon Sep 17 00:00:00 2001 From: Lucio Delelis Date: Fri, 4 Oct 2019 00:12:16 -0300 Subject: [PATCH] feat(): implements core help module --- modules/help.ts | 25 +++++++++++++++++++++++++ scepter.ts | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 modules/help.ts diff --git a/modules/help.ts b/modules/help.ts new file mode 100644 index 0000000..0077f36 --- /dev/null +++ b/modules/help.ts @@ -0,0 +1,25 @@ +import { Message } from 'discord.js' +import { Command } from '../scepter' + +export const help = async (message: Message, args: string[]) => { + const helpCommand = args[0] + const command: Command = message.client['loadedCommands'][helpCommand] + + if (command == null) { + return message.channel.send(`Command not found: ${helpCommand}`) + } + return message.channel.send(`${helpCommand}: ${command.description}\n\ +Examples: \`${command.examples.map(x => x)}\``) +} + +export const name = 'help' +export const commands = [ + { + name: 'help', + description: 'Shows info and usage details of a given command', + examples: ['s.help help'], + minArgs: 1, + maxArgs: 1, + run: help + } +] diff --git a/scepter.ts b/scepter.ts index 3a050ae..b215031 100644 --- a/scepter.ts +++ b/scepter.ts @@ -48,7 +48,7 @@ if (!process.env.SCEPTER_DISCORD_TOKEN) { client.login(process.env.SCEPTER_DISCORD_TOKEN) .catch(console.error) -type Command = { +export type Command = { name: string, description: string, examples: string[],