forked from tuhinpal/WhatsBot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathud.js
45 lines (42 loc) · 1.1 KB
/
ud.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//jshint esversion:8
const dictionary = require("urban-dictionary");
async function ud(term) {
try {
return await dictionary.define(term);
} catch (error) {
return "error";
}
}
const execute = async (client, msg, args) => {
msg.delete(true);
let data = await ud(args.join(" "));
if (data == "error") {
await client.sendMessage(
msg.to,
`🙇♂️ *Error*\n\n` +
"```Something Unexpected Happened while Lookup on Urban Dictionary```"
);
} else {
await client.sendMessage(
msg.to,
"*Term:* ```" +
args.join(" ") +
"```\n\n" +
"*Definition:* ```" +
data[0].definition +
"```\n\n" +
"*Example:* ```" +
data[0].example +
"```"
);
}
};
module.exports = {
name: "Urban Dictionary",
description: "Gets dictionary meanings of words",
command: "!ud",
commandType: "plugin",
isDependent: false,
help: `*Urban Dictionary*\n\nUrban Dictionary is a crowdsourced online dictionary for slang words and phrases.\n\n*!ud [Word]*\nto search a word using Urban Dictionary`,
execute,
};