From 15d41b6ac8aabad9c3d0e65c9a14b404de19fe43 Mon Sep 17 00:00:00 2001 From: Chipmunk <65827213+ChipmunkMC@users.noreply.github.com> Date: Sun, 1 Jan 2023 01:02:04 +0000 Subject: [PATCH] Rewrite `urban` command --- commands/urban.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/commands/urban.js b/commands/urban.js index 290355c..813cb4e 100644 --- a/commands/urban.js +++ b/commands/urban.js @@ -5,15 +5,11 @@ module.exports = { description: 'Working Urban Dictionary', usage: '', trusted: 0, - execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { - urban.autocompleteExtra(args[0], (error, results) => { - if (error) { - bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: error.message, color: 'red' }]) - return - } - results.forEach(({ preview, term }) => { - bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: term, color: 'white' }, { text: ' - ', color: 'white' }, { text: preview, color: 'white' }]) - }) - }) + async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { + const definitions = await urban.define(args.join(' ')) + + for (const definition of definitions) { + bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: definition.word, color: 'white' }, { text: ' - ', color: 'white' }, { text: definition.definition, color: 'white' }]) + } } }