diff --git a/src/bot/commands/ICommand.ts b/src/bot/commands/ICommand.ts index c359bcf..76ec39f 100644 --- a/src/bot/commands/ICommand.ts +++ b/src/bot/commands/ICommand.ts @@ -4,5 +4,6 @@ export default interface ICommand { name: string; aliases?: string[]; description: string; + example?: string; execute: (message: Discord.Message, args: string[], prefix?: string, commands?: Collection) => Promise, } \ No newline at end of file diff --git a/src/bot/commands/help.ts b/src/bot/commands/help.ts index 7d7d49e..b4218f7 100644 --- a/src/bot/commands/help.ts +++ b/src/bot/commands/help.ts @@ -1,18 +1,35 @@ import Discord, { Collection } from 'discord.js'; - import ICommand from './ICommand'; +import ConfigService from '../../core/services/config.service' +import container from '../../inversity.config'; +const prefix = container.resolve(ConfigService).get('BOT_TRIGGER'); const command: ICommand = { name: 'help', aliases: ['commands'], - description: 'Lists available commands.', + example: `\`${prefix}help ping\``, + description: 'Lists available commands!', async execute(message: Discord.Message, args: string[], prefix: string, commands: Collection) { const data = []; if (!args.length) { // Get for all commands - data.push('Here\'s a list of all my commands:\n'); - data.push(commands.map(command => command.name).join(', ')); + data.push('here\'s a list of all my commands:\n'); + + const cmds = commands.map(command => command.name); + let cmd; + cmds.forEach(element => { + cmd = commands.get(element) || commands.find(c => c.aliases && c.aliases.includes(element)); + let response = `\`${prefix}${cmd.name}\` `; + if (cmd.description) { + response += `**${cmd.description}** `; + } + if (cmd.aliases) { + response += `\n\t\t\t*alternatively:* \`${prefix}${cmd.aliases.join(`\`, \`${prefix}`)}\``; + } + data.push(response); + data.push(cmd.example ? `\t\t\t*for example:* ${cmd.example}\n` : ''); + }); data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`); } else { // Get description of single command @@ -29,13 +46,12 @@ const command: ICommand = { } } - - try { - await message.author.send(data, { split: true }); - if (message.channel.type === 'dm') - return; - message.reply('I\'ve sent you a DM with all my commands!'); + //await message.author.send(data, { split: true }); + //if (message.channel.type === 'dm') + // return; + // message.reply('I\'ve sent you a DM with all my commands!'); + message.reply(data, { split: true }) } catch (error) { console.error(`Could not send help DM to ${message.author.tag}.\n`, error); diff --git a/src/bot/commands/ping.ts b/src/bot/commands/ping.ts index 473db61..2cf235b 100644 --- a/src/bot/commands/ping.ts +++ b/src/bot/commands/ping.ts @@ -1,13 +1,12 @@ import Discord from 'discord.js'; - import ICommand from './ICommand'; const command: ICommand = { name: 'ping', - aliases: ['hello'], + aliases: ['hello', 'hi'], description: 'Responds, kind of like telling you the bot is alive.', async execute(message: Discord.Message, args: string[]) { - message.reply('Pong.'); + message.reply('Pong!'); }, }; diff --git a/src/bot/commands/see.ts b/src/bot/commands/see.ts index f05ed19..38287ff 100644 --- a/src/bot/commands/see.ts +++ b/src/bot/commands/see.ts @@ -1,9 +1,13 @@ import Discord from 'discord.js'; import ICommand from './ICommand'; +import ConfigService from '../../core/services/config.service' +import container from '../../inversity.config'; +const prefix = container.resolve(ConfigService).get('BOT_TRIGGER'); const command: ICommand = { name: 'see', + example: `\`${prefix}see\``, description: 'Sends a DM telling you information about your user on given server.', async execute(message: Discord.Message, args: string[]) { message.author.send(`Server: ${message.guild.name}\nYour username: ${message.author.username}\nYour ID: ${message.author.id}`);