Destructuring Args

This commit is contained in:
Daniel Odendahl Jr
2017-04-19 12:21:38 +00:00
parent 4fc536531d
commit e105b6aa5d
72 changed files with 228 additions and 167 deletions
+5 -2
View File
@@ -19,7 +19,10 @@ module.exports = class DefineCommand extends Command {
args: [{
key: 'word',
prompt: 'What would you like to define?',
type: 'string'
type: 'string',
parse: text => {
return encodeURIComponent(text);
}
}]
});
}
@@ -29,7 +32,7 @@ module.exports = class DefineCommand extends Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
}
const word = encodeURIComponent(args.word);
const { word } = args;
try {
const response = await request
.get(`http://api.wordnik.com:80/v4/word.json/${word}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`);