fix: type related issues to webhooks

This commit is contained in:
izzy
2025-04-04 15:03:10 +01:00
parent d7b68107e0
commit 15baa67c76
4 changed files with 1067 additions and 875 deletions
+1 -1
View File
@@ -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",
+1064 -853
View File
File diff suppressed because it is too large Load Diff
+2 -17
View File
@@ -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);
}