updated for UD
This commit is contained in:
@@ -16,6 +16,7 @@ module.exports = {
|
||||
**!random** - Selects a random article: *!random*
|
||||
**!random category** - Selects a random article by category: *!random sports*
|
||||
**!answer** - Instant Live Search: *!answer salesforce*
|
||||
**!slang** - Urban Dictionary Search: *!answer slang*
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
17
commands/slang.js
Normal file
17
commands/slang.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var libFlayer = require("../libFlayer.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'slang',
|
||||
description: 'Slang',
|
||||
async execute(message,args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
message.reply(`Please use in !slang [question] format`);
|
||||
return;
|
||||
}
|
||||
var question = encodeURIComponent(args.join(" "));
|
||||
|
||||
var slangData = await libFlayer.getSlang(question);
|
||||
message.reply(`${slangData.definition} - ${slangData.example}`);
|
||||
}
|
||||
};
|
||||
27
libFlayer.js
27
libFlayer.js
@@ -239,6 +239,33 @@ exports.getAnswer = async function (question) {
|
||||
return answerData;
|
||||
}
|
||||
|
||||
exports.getSlang = async function (question) {
|
||||
|
||||
var answerURL = `https://api.urbandictionary.com/v0/define?term=${question}`;
|
||||
console.log(answerURL);
|
||||
slangData = {
|
||||
definition: `No answer found try using a simpler search term`,
|
||||
example: ``
|
||||
}
|
||||
await axios.get(answerURL)
|
||||
.then(response => {
|
||||
console.log(response.data.list[0]);
|
||||
|
||||
slangData = {
|
||||
definition: `${unescape(response.data.list[0].definition)}`,
|
||||
example: `${unescape(response.data.list[0].example)}`,
|
||||
thumbs_down: `${unescape(response.data.list[0].thumbs_down)}`,
|
||||
thumbs_up: `${unescape(response.data.list[0].thumbs_up)}`
|
||||
}
|
||||
|
||||
return slangData;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
return slangData;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSources - Returns libFlayer feed sources
|
||||
* @constructor
|
||||
|
||||
Reference in New Issue
Block a user