()
| 2 | |
| 3 | class DogCommand 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 imageData = await fetch("https://dog.ceo/api/breeds/image/random", { signal: controller.signal }); |
| 12 | clearTimeout(timeout); |
| 13 | const json = await imageData.json(); |
| 14 | return json.message; |
| 15 | } catch (e) { |
| 16 | if (e instanceof DOMException && e.name === "AbortError") { |
| 17 | this.success = false; |
| 18 | return this.getString("commands.responses.dog.error"); |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | static description = "Gets a random dog picture"; |
| 24 | static aliases = ["doggos", "doggo", "pupper", "puppers", "dogs", "puppy", "puppies", "pups", "pup"]; |
nothing calls this directly
no test coverage detected