()
| 2 | |
| 3 | class 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"]; |
nothing calls this directly
no test coverage detected