mvrilo / urban Goto Github PK
View Code? Open in Web Editor NEWCommand line tool and API for the Urban Dictionary
Home Page: https://mvrilo.github.io/urban/
License: MIT License
Command line tool and API for the Urban Dictionary
Home Page: https://mvrilo.github.io/urban/
License: MIT License
The npm description does not explain too much about how to use this package so Im going to ask here.
If I wanted to get an array of search results for a search term, how would i go about doing that?
Hello, I am using this package for my discord bot which uses Discord.js v13. Upon using it I get this error:
[ERROR] SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at IncomingMessage.<anonymous> (C:\Users\User\Desktop\Durchie v13\node_modules\urban\lib\urban.js:83:24) at IncomingMessage.emit (node:events:406:35) at endReadableNT (node:internal/streams/readable:1331:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)
Any idea why?
This command has been working forever with no issues, today though I got an error, as I have not changed my code, and it's an error within the node module, I think the API must have changed.
My Code:
const { del } = require("../../functions.js");
const urban = require("urban");
const { MessageEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");
module.exports = {
name: "urban",
aliases: ["urb", "urbandictionary", "ud"],
category: "fun",
description: "Gets an urban dictionary definition",
usage: "[search <term> | random]",
permissions: "member",
run: (client, message, args) => {
if (!args[0] || !["search", "random"].includes(args[0]))
return message.reply("Please provide <search|random> (query).").then(m => del(m, 7500));
let search = args[1] ? urban(args.slice(1).join(" ")) : urban.random();
try {
search.first(res => {
if (!res) return message.reply("No results found for this topic, sorry!").then(m => del(m, 7500));
let { word, definition, example, thumbs_up, thumbs_down, permalink, author } = res;
let description = stripIndents`**Defintion:** ${definition || "No definition"}
**Example:** ${example || "No Example"}
**Upvote:** ${thumbs_up || 0}
**Downvote:** ${thumbs_down || 0}
**Link:** [link to ${word}](${permalink || "https://www.urbandictionary.com/"})`
if (description.length >= 1024)
return message.reply("This definition is too long of a string for a message embed sorry!").then(m => del(m, 7500));
else {
let embed = new MessageEmbed()
.setColor("#0efefe")
.setAuthor(`Urban Dictionary | ${word}`, image)
.setDescription(description)
.setTimestamp()
.setFooter(`Written by ${author || "unknown"}`);
message.channel.send(embed)
}
});
} catch (err) {
return message.channel.send(`Error while searching... ${err}`).then(m => del(m, 7500));
}
}
}
Error Caught by my process.on(uncaughtExcemption) event not the catch statement:
10-05-2021 12-18-44 A new uncaughtExcemption error: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\urban\lib\urban.js:83:24)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) at: uncaughtException
Am I right in thinking this doesn't support multi-word entries, e.g. "presidential flashcards"?
When I do this:
var urban = require('urban'),
catfish = urban('catfish');
catfish.first(function(json) {
console.log(json);
});
Dictionary.fn.getData @ https://github.com/mvrilo/urban/blob/master/lib/urban.js#L66
The above script will create a URL for the GET request and it doesn't work anymore
http://api.urbandictionary.com/v0/define?page=undefined&term=catfish
if you remove page=undefined
though, it works
http://api.urbandictionary.com/v0/define?term=catfish
Is anyone else experiencing this? this lib just completely stopped working for me recently and it's just for this small reason.
When trying to install, I get this error.
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Required: {"node":">= 0.4.x < 0.7.0"}
npm ERR! notsup Actual: {"npm":"3.3.3","node":"4.2.2"}
From what I can see API of Urban Dic. puts the definition with most thumbs up first. Many times this cause a bad selection of definition. Is there a way to take the definition with highest(thumbs_up - thumbs_down) ?
There is at least one bug fix in the git repo that's not in the npm version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.