Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on('message', async message => {
- if (message.author.bot || message.channel.type === 'dm') return;
- if (!message.content.startsWith(prefix)) return;
- let cmd = message.content.split(" ")[0].substring(prefix.length);
- let args = message.content.split(" ");
- if (cmd === 'urban') {
- if (!args[1]) return;
- let o = await message.channel.send(`**• Getting data, Please wait...**`);
- let i = new Discord.RichEmbed();
- i.setColor("#36393e");
- let string = query.stringify({
- term: args.slice(1).join(" ")
- });
- fetch(`http://api.urbandictionary.com/v0/define?${string}`)
- .then(async res => res.json())
- .then(async res => {
- let data = res.list;
- if (!data.length || data.length === 0) {
- o.delete();
- return message.channel.send(`**• Couldn't search \`${args.slice(1).join(" ").slice(0, 1024)}\`**`);
- }
- let info = data[0];
- i.addField('❯ General', `→ Definition: \`${info.definition}\`\n→ Link: [${info.word}](${info.permalink})\n→ Author: \`${info.author}\``);
- i.addField('❯ Rating', `→ Agreed: \`${info.thumbs_up}\`\n→ Disagreed: \`${info.thumbs_down}\`\n→ Votes: \`${info.thumbs_up + info.thumbs_down}\``);
- i.addField('❯ Example', `→ \`${info.example}\``);
- i.setThumbnail("https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2018-01-11/297387706245_85899a44216ce1604c93_512.jpg");
- i.setFooter("Urban Dictionary", "https://s3.amazonaws.com/pushbullet-uploads/ujxPklLhvyK-RGDsDKNxGPDh29VWVd5iJOh8hkiBTRyC/urban_dictionary.jpg?w=188&h=188&fit=crop");
- // ❯ , →
- await o.delete().catch(e => {});
- await message.channel.send(i);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement