mrmBot-Matrix/commands/fun/ancient.js

33 lines
883 B
JavaScript
Raw Normal View History

import fetch from "node-fetch";
import Command from "../../classes/command.js";
class AncientCommand extends Command {
async run() {
await this.acknowledge();
const controller = new AbortController();
const timeout = setTimeout(() => {
controller.abort();
}, 15000);
try {
const data = await fetch("https://projectlounge.pw/meme/", { redirect: "manual", signal: controller.signal });
clearTimeout(timeout);
return {
2021-11-10 04:09:10 +00:00
embeds: [{
color: 16711680,
image: {
url: data.headers.get("location")
}
2021-11-10 04:09:10 +00:00
}]
};
} catch (e) {
if (e.name === "AbortError") {
return "I couldn't get a meme in time. Maybe try again?";
}
}
}
static description = "Gets a random ancient meme";
static aliases = ["old", "oldmeme", "badmeme"];
}
export default AncientCommand;