mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-19 17:13:31 -04:00
fix: type related issues to webhooks
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "7.1.0-rc.2",
|
||||
"version": "7.1.0-rc.3",
|
||||
"type": "module",
|
||||
"module": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
||||
Generated
+1064
-853
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import * as APITmp from "revolt-api";
|
||||
import { DataEditWebhook } from "revolt-api";
|
||||
|
||||
import type { ChannelWebhookCollection } from "../collections/ChannelWebhookCollection.js";
|
||||
import { hydrate } from "../hydration/index.js";
|
||||
@@ -78,29 +78,15 @@ export class ChannelWebhook {
|
||||
|
||||
/**
|
||||
* Edit this webhook
|
||||
* TODO: not in production
|
||||
*/
|
||||
async edit(
|
||||
data: Partial<{
|
||||
name: string;
|
||||
avatar: string;
|
||||
permissions: number;
|
||||
remove: ["Icon"];
|
||||
}>,
|
||||
): Promise<void> {
|
||||
// @ts-expect-error this should error once edit webhook is stable
|
||||
// eslint-disable-next-line
|
||||
type TodoUseThisDefinitionOnceItExists = APITmp.DataEditWebhook;
|
||||
|
||||
async edit(data: DataEditWebhook): Promise<void> {
|
||||
const webhook = await this.#collection.client.api.patch(
|
||||
// @ts-expect-error not in prod
|
||||
`/webhooks/${this.id as ""}/${this.token as ""}`,
|
||||
data,
|
||||
);
|
||||
|
||||
this.#collection.updateUnderlyingObject(
|
||||
this.id,
|
||||
// @ts-expect-error not in prod
|
||||
hydrate("channelWebhook", webhook, this.#collection.client),
|
||||
);
|
||||
}
|
||||
@@ -111,7 +97,6 @@ export class ChannelWebhook {
|
||||
*/
|
||||
async delete(): Promise<void> {
|
||||
await this.#collection.client.api.delete(
|
||||
// @ts-expect-error not in prod
|
||||
`/webhooks/${this.id}/${this.token}`,
|
||||
);
|
||||
|
||||
|
||||
@@ -20,9 +20,7 @@ export class ChannelWebhookCollection extends ClassCollection<
|
||||
async fetch(id: string): Promise<ChannelWebhook> {
|
||||
const webhook = this.get(id);
|
||||
if (webhook) return webhook;
|
||||
// @ts-expect-error not in prod
|
||||
const data = await this.client.api.get(`/webhooks/${id as ""}`);
|
||||
// @ts-expect-error not in prod
|
||||
return this.getOrCreate(data.id, data as Webhook);
|
||||
}
|
||||
|
||||
@@ -36,10 +34,8 @@ export class ChannelWebhookCollection extends ClassCollection<
|
||||
const webhook = this.get(id);
|
||||
if (webhook) return webhook;
|
||||
const data = await this.client.api.get(
|
||||
// @ts-expect-error not in prod
|
||||
`/webhooks/${id as ""}/${token as ""}`,
|
||||
);
|
||||
// @ts-expect-error not in prod
|
||||
return this.getOrCreate(data.id, data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user