Skip to content

Commit

Permalink
Simplify command prefixing
Browse files Browse the repository at this point in the history
  • Loading branch information
acdvs committed Jul 2, 2020
1 parent 77043d2 commit 2b66cf3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
20 changes: 13 additions & 7 deletions lib/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
'use strict';

const PREFIX = require('./index').COMMAND_PREFIX;

/**
* !help
* @param {Object} msg Discord message
*/
module.exports = (msg) => {
msg.channel.send([
'```',
'Commands: help, deals, wishlist, add, delete\n',
'-Help: !help',
' Go help yourself to some good deals.',
'-Deals: !deals [game name]',
' Current deals on a specific game',
'-WishList: !wishlist [game names]',
' Current deals on multiple games, add a \'-\' for games',
'Commands: help, deals, wishlist, ignoredsellers\n',
`- ${PREFIX}help`,
' This command',
`- ${PREFIX}deals [game name]`,
' Gets current deals on a specific game',
`- ${PREFIX}wishlist [game names]`,
' Gets current deals on multiple games, add a \'-\' for games',
' with multiple words',
`- ${PREFIX}ignoredsellers`,
' Lists all ignored sellers',
`- ${PREFIX}ignoredsellers [add|remove] [seller]`,
' Adds or removes an ignored seller',
'```'
].join('\n'));
};
1 change: 1 addition & 0 deletions lib/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

module.exports = {
COMMAND_PREFIX: '!',
help: require('./help'),
deals: require('./deals'),
wishlist: require('./wishlist'),
Expand Down
14 changes: 6 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ const bot = new Discord.Client();
const commands = require('./commands');
const settingsUtil = require('./util/settings');

const COMMAND_PREFIX = '!';
const C_HELP = `${COMMAND_PREFIX}help`;
const C_DEALS = `${COMMAND_PREFIX}deals`;
const C_WISHLIST = `${COMMAND_PREFIX}wishlist`;
const C_IGNORED_SELLERS = `${COMMAND_PREFIX}ignoredsellers`;
const C_ADD = `${COMMAND_PREFIX}add`;
const C_REMOVE = `${COMMAND_PREFIX}remove`;
const PREFIX = commands.COMMAND_PREFIX;
const C_HELP = 'help';
const C_DEALS = 'deals';
const C_WISHLIST = 'wishlist';
const C_IGNORED_SELLERS = 'ignoredsellers';

let settings = settingsUtil.DEFAULT_SETTINGS;

Expand Down Expand Up @@ -43,7 +41,7 @@ bot.on('ready', async () => {
bot.on('message', async (msg) => {
const [command, options] = msg.content.split(/\s+(.*)/);

switch (command) {
switch (command.substring(PREFIX.length)) {
case C_HELP:
commands.help(msg);
break;
Expand Down

0 comments on commit 2b66cf3

Please sign in to comment.