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

Method run

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

Source from the content-addressed store, hash-verified

2
3class 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"];

Callers

nothing calls this directly

Calls 2

acknowledgeMethod · 0.80
getStringMethod · 0.80

Tested by

no test coverage detected