Merge pull request #1 from ChipmunkMC/improve-urban-command

Rewrite `urban` command
This commit is contained in:
Chayapak 2023-01-01 08:03:05 +07:00 committed by GitHub
commit e049a9e0ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,15 +5,11 @@ module.exports = {
description: 'Working Urban Dictionary',
usage: '<word>',
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' }])
}
}
}