2023-03-15 14:09:09 +00:00
|
|
|
import { request } from "undici";
|
|
|
|
import Command from "../../classes/command.js";
|
|
|
|
|
|
|
|
class CatCommand extends Command {
|
|
|
|
async run() {
|
2023-03-17 00:23:01 +00:00
|
|
|
// await this.acknowledge();
|
2023-03-15 14:09:09 +00:00
|
|
|
const controller = new AbortController();
|
|
|
|
const timeout = setTimeout(() => {
|
|
|
|
controller.abort();
|
|
|
|
}, 15000);
|
|
|
|
try {
|
|
|
|
const data = await request("https://files.projectlounge.pw/cta/", { method: "HEAD", signal: controller.signal });
|
|
|
|
clearTimeout(timeout);
|
|
|
|
return `https://files.projectlounge.pw${data.headers.location}`;
|
|
|
|
} catch (e) {
|
|
|
|
if (e.name === "AbortError") {
|
|
|
|
this.success = false;
|
|
|
|
return "I couldn't get a cat image in time. Maybe try again?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static description = "Gets a random cat picture";
|
|
|
|
static aliases = ["kitters", "kitties", "kitty", "cattos", "catto", "cats", "cta"];
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:19:14 +00:00
|
|
|
export default CatCommand;
|