Advertisement
n3k4a

URban

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