Cuu.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. /* eslint-disable import/prefer-default-export */
  2. /* eslint-disable @typescript-eslint/no-unsafe-call */
  3. /* eslint-disable @typescript-eslint/no-unsafe-assignment */
  4. /* eslint-disable @typescript-eslint/no-unsafe-member-access */
  5. /* eslint-disable @typescript-eslint/no-unsafe-return */
  6. import { Message } from 'discord.js';
  7. import * as database from '../utils/database';
  8. import * as anime from '../functions/anime';
  9. import * as sources from '../utils/sources';
  10. export default async (message: Message, ...args: string[]): Promise<void> => {
  11. if (args.length <= 0) {
  12. const data = await database.load(message.author.id);
  13. if (data.length > 0) {
  14. await message.channel.send({
  15. embeds: data.map((d) => ({
  16. title: 'CuuBot',
  17. image: {
  18. url: d.url,
  19. },
  20. })),
  21. });
  22. await database.remove(message.author.id);
  23. }
  24. return;
  25. }
  26. if (args.join(' ').toLowerCase() === 'cuu') {
  27. const data = await sources.fetchBooru('thighhighs');
  28. const NOT_FOUND_MESSAGES = [
  29. 'No images found.',
  30. ];
  31. if (data.post.length <= 0) {
  32. await message.channel.send(
  33. NOT_FOUND_MESSAGES[Math.floor(Math.random() * NOT_FOUND_MESSAGES.length)]
  34. );
  35. return;
  36. }
  37. await message.channel.send({
  38. embeds: [
  39. {
  40. title: 'CuuBot',
  41. image: {
  42. url: data.post[0].file_url as string,
  43. },
  44. },
  45. ],
  46. });
  47. return;
  48. }
  49. const [subject] = args;
  50. await anime.replyRandomImage(message, subject);
  51. };