MCPcopy Create free account
hub / github.com/esmBot/esmBot / run

Method run

commands/fun/bird.js:4–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3class BirdCommand extends Command {
4 async run() {
5 await this.acknowledge();
6 const controller = new AbortController();
7 const timeout = setTimeout(() => {
8 controller.abort();
9 }, 15000);
10 try {
11 const data = await fetch("https://files.esmbot.net/bird", {
12 method: "HEAD",
13 signal: controller.signal,
14 redirect: "manual",
15 });
16 clearTimeout(timeout);
17 return `https://files.esmbot.net${data.headers.get("location")}`;
18 } catch (e) {
19 if (e instanceof DOMException && e.name === "AbortError") {
20 this.success = false;
21 return this.getString("commands.responses.bird.error");
22 }
23 }
24 }
25
26 static description = "Gets a random bird picture";
27 static aliases = ["birb", "birds", "birbs"];

Callers

nothing calls this directly

Calls 2

acknowledgeMethod · 0.80
getStringMethod · 0.80

Tested by

no test coverage detected