mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 10:19:11 +02:00
Urban Dictionary Command Added
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
const commando = require('discord.js-commando');
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const urban = require('urban');
|
||||||
|
|
||||||
|
class UrbanDictionary extends commando.Command {
|
||||||
|
constructor(Client){
|
||||||
|
super(Client, {
|
||||||
|
name: 'urban',
|
||||||
|
group: 'response',
|
||||||
|
memberName: 'urban',
|
||||||
|
description: 'Searches Urban Dictionary. (;urban Cat)',
|
||||||
|
examples: [';urban Cat']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, args) {
|
||||||
|
if(message.channel.type !== 'dm') {
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
|
||||||
|
}
|
||||||
|
console.log("[Command] " + message.content);
|
||||||
|
let wordtodefine = message.content.split(" ").slice(1).join(" ");
|
||||||
|
urban(wordtodefine).first(function(json) {
|
||||||
|
if(json === undefined) {
|
||||||
|
message.reply(":x: Error! Word not found!");
|
||||||
|
} else if(json.definition === '') {
|
||||||
|
message.reply(":x: Error! Word has no definition!");
|
||||||
|
} else if(json.example === '') {
|
||||||
|
const embed = new Discord.RichEmbed()
|
||||||
|
.setColor(0x0000FF)
|
||||||
|
.setAuthor('Urban Dictionary', 'https://lh3.googleusercontent.com/4hpSJ4pAfwRUg-RElZ2QXNh_pV01Z96iJGT2BFuk_RRsNc-AVY7cZhbN2g1zWII9PBQ=w170', json.permalink)
|
||||||
|
.setDescription(json.word)
|
||||||
|
.addField('Definition:',
|
||||||
|
json.definition);
|
||||||
|
message.channel.sendEmbed(embed).catch(console.error);
|
||||||
|
} else {
|
||||||
|
const embed = new Discord.RichEmbed()
|
||||||
|
.setColor(0x0000FF)
|
||||||
|
.setAuthor('Urban Dictionary', 'https://lh3.googleusercontent.com/4hpSJ4pAfwRUg-RElZ2QXNh_pV01Z96iJGT2BFuk_RRsNc-AVY7cZhbN2g1zWII9PBQ=w170', json.permalink)
|
||||||
|
.setDescription(json.word)
|
||||||
|
.addField('Definition:',
|
||||||
|
json.definition)
|
||||||
|
.addField('Example:',
|
||||||
|
json.example);
|
||||||
|
message.channel.sendEmbed(embed).catch(console.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = UrbanDictionary;
|
||||||
+2
-1
@@ -17,6 +17,7 @@
|
|||||||
"discord.js-commando": "^0.9.0",
|
"discord.js-commando": "^0.9.0",
|
||||||
"google-translate-api": "^2.2.2",
|
"google-translate-api": "^2.2.2",
|
||||||
"jimp": "^0.2.27",
|
"jimp": "^0.2.27",
|
||||||
"pirate-speak": "^1.0.1"
|
"pirate-speak": "^1.0.1",
|
||||||
|
"urban": "^0.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user