Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@vladfrangu/async_event_emitter": "^2.4.7",
"json-with-bigint": "^3.4.4",
"solid-js": "^1.9.14",
"stoat-api": "0.14.3",
"stoat-api": "0.15.3",
"ulid": "^3.0.2"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion src/classes/Bot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DataEditBot } from "stoat-api";
import type { DataEditBot, DiscoverRequest } from "stoat-api";
import { decodeTime } from "ulid";

import type { BotCollection } from "../collections/BotCollection.js";
Expand Down Expand Up @@ -158,4 +158,31 @@ export class Bot {
await this.#collection.client.api.delete(`/bots/${this.id as ""}`);
this.#collection.delete(this.id);
}

/**
* Add bot to the discover request queue
*/
async requestDiscover(): Promise<void> {
await this.#collection.client.api.put(`/bots/${this.id as ""}/discover`);
}

/**
* Get the status of the discover request for this bot
* @returns The discovery request for this bot if one exists
*/
async discoverRequestStatus(): Promise<DiscoverRequest> {
return await this.#collection.client.api.get(
`/bots/${this.id as ""}/discover`,
);
}

/**
* Cancel the discover request for this bot
*
* This cannot be used to remove bots from discover that have already been accepted
* and should only be called on bots that have an outstanding discover request.
*/
async cancelDiscoverRequest() {
await this.#collection.client.api.delete(`/bots/${this.id as ""}/discover`);
}
}
30 changes: 30 additions & 0 deletions src/classes/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
DataCreateServerChannel,
DataEditRole,
DataEditServer,
DiscoverRequest,
Override,
Role,
} from "stoat-api";
Expand Down Expand Up @@ -852,4 +853,33 @@ export class Server {

return highest;
}

/**
* Add server to the discover request queue
*/
async requestDiscover(): Promise<void> {
await this.#collection.client.api.put(`/servers/${this.id as ""}/discover`);
}

/**
* Get the status of the discover request for this server
* @returns The discovery request for this server if one exists
*/
async discoverRequestStatus(): Promise<DiscoverRequest> {
return await this.#collection.client.api.get(
`/servers/${this.id as ""}/discover`,
);
}

/**
* Cancel the discover request for this server
*
* This cannot be used to remove servers from discover that have already been accepted
* and should only be called on servers that have an outstanding discover request.
*/
async cancelDiscoverRequest() {
await this.#collection.client.api.delete(
`/servers/${this.id as ""}/discover`,
);
}
}
Loading