rcg.ts 794 B

1234567891011121314151617181920212223242526
  1. import request from "request-promise-native";
  2. import { Message } from "discord.js";
  3. import { Command, CommandSet } from "src/model/command";
  4. const rcgRe = /<input id="rcg_image".+value="([^"]+)".*\/>/i;
  5. @CommandSet
  6. export class Rcg {
  7. @Command({
  8. pattern: "random comic",
  9. auth: false,
  10. documentation: {description: "Generates a comic just for you!", example: "random comic"}
  11. })
  12. async randomComic(msg: Message) {
  13. let result = await request("http://explosm.net/rcg/view/?promo=false");
  14. let regexResult = rcgRe.exec(result);
  15. if(!regexResult)
  16. return;
  17. msg.channel.send(`${msg.author.toString()} I find this very funny:`, {
  18. files: [ regexResult[1].trim() ]
  19. });
  20. }
  21. };