Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. const { each } = require('bluebird');
  2. const _ = require('lodash');
  3. const Booru = require('booru');
  4. const site = 'danbooru';
  5. // for ES6:
  6. // import Booru, { search, BooruError, sites } from 'booru'
  7.  
  8. module.exports = {
  9. name: 'art',
  10. description: 'Get two random images from danbooru (sfw by danbooru ratings)',
  11. async execute(message, args) {
  12. try {
  13. await each(
  14. _(await Booru.search(site, args, { limit: 100, random: true }))
  15. .filter(post => (post || {}).rating === 's' && (post || {}).previewUrl !== null)
  16. .take(2),
  17. post => {console.log(args); message.channel.send(post.postView);},
  18. );
  19. }
  20. catch (error) {
  21. console.log(args);
  22. if (args.length > 2) {
  23. message.reply('You cannot search for more than two tags at a time!');
  24. }
  25. else {
  26. message.channel.send('Something went wrong.');
  27. console.error(error.message || error);
  28. }
  29. }
  30. },
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement