Skip to content
This repository has been archived by the owner on Jan 31, 2021. It is now read-only.

Commit

Permalink
Add query to deck list, make deck list spammy again, fix help with op…
Browse files Browse the repository at this point in the history
…tional args
  • Loading branch information
dragonfire535 committed Aug 21, 2018
1 parent 67b687e commit 9611296
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion commands/info/deck-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = class DeckInfoCommand extends Command {
.addField('❯ Official?', deck.official ? 'Yes' : 'No', true)
.addField('❯ View', `[Here](${url})`, true)
.addField('❯ Black Cards', deck.blackCards.length, true)
.addField('❯ White Cards', deck.whiteCards.length, true);
.addField('❯ White Cards', deck.whiteCards.length, true)
.addField('❯ Total Cards', deck.blackCards.length + deck.whiteCards.length, true);
return msg.util.send({ embed });
}
};
21 changes: 18 additions & 3 deletions commands/info/deck-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@ module.exports = class DeckListCommand extends Command {
super('deck-list', {
aliases: ['deck-list', 'decks'],
category: 'other',
description: 'Responds with a list of all decks.'
description: 'Responds with a list of all decks, with query.',
args: [
{
id: 'query',
prompt: {
start: 'What deck would you like to search for?',
retry: 'You provided an invalid query. Please try again.',
optional: true
},
default: '',
type: 'string'
}
]
});
}

exec(msg) {
return msg.util.send(this.client.decks.map(deck => `${deck.name} (${deck.id})`).join(', '));
exec(msg, { query }) {
const search = query.toLowerCase();
let results = this.client.decks;
if (query) results = this.client.decks.filter(d => d.id.includes(search) || d.name.toLowerCase().includes(search));
return msg.util.send(results.map(deck => `${deck.name} (${deck.id})`).join(', '));
}
};
4 changes: 2 additions & 2 deletions commands/util/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ module.exports = class HelpCommand extends Command {
makeArgList(args) {
return args.map(arg => {
let result = '';
result += args.optional || arg.flag ? '[' : '<';
result += (arg.prompt && arg.prompt.optional) || arg.flag ? '[' : '<';
if (arg.prompt && arg.prompt.infinite) result += '...';
if (arg.flag) result += arg.flag.join('|');
else result += arg.id;
result += args.optional || arg.flag ? ']' : '>';
result += (arg.prompt && arg.prompt.optional) || arg.flag ? ']' : '>';
return result;
}).join(' ');
}
Expand Down

0 comments on commit 9611296

Please sign in to comment.