woomy/src/commands/urban.js

49 lines
1.7 KiB
JavaScript

Discord = require("discord.js");
urban = require("relevant-urban");
exports.run = async (client, message, args) => {
if (message.channel.nsfw === false) return message.channel.send(
"<:error:466995152976871434> This command can only be executed in channels marked as NSFW!"
);
if (args < 1) return message.channel.send(
`<:error:466995152976871434> You did not tell me what to search for! Usage: \`${client.commands.get(`urban`).help.usage}\`
`);
let phrase = args.join(" ");
let output = await urban(args.join(' ')).catch(e => {
return message.channel.send("<:error:466995152976871434> No results found for `" + phrase + "`")
});
if(output.definition.length > 2000) return message.channel.send(
`<:error:466995152976871434> Definition cannot exceed 2000 characters! Use this link instead: ${output.urbanURL}`
);
if(output.example.length > 2000) return message.channel.send(
"<:error:466995152976871434> Example cannot exceed 2000 characters!"
);
embed = new Discord.MessageEmbed()
.setTitle(output.word)
.setURL(output.urbanURL)
.setColor("#EFFF00")
.setDescription(output.definition || "None")
.addFields(
{name: "Example", value: output.example || "None"}, {name: "Upvotes", value: output.thumbsUp, inline: true}, {name: "Downvotes", value: output.thumbsDown, inline: true}
)
.setFooter(`Submitted by ${output.author}`)
message.channel.send(embed);
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: "User",
requiredPerms: []
};
exports.help = {
name: "urban",
category: "Fun",
description: "Grabs a definition from the urban dictonary.",
usage: "urban [word]"
};