mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 12:36:08 +00:00
fix: Error with ThreadChannel#webhooks for bad patchClass interaction (#341)
This commit is contained in:
parent
e4f715515c
commit
5de23ffe58
@ -581,13 +581,15 @@ export class ForumChannel extends BaseGuildChannel {
|
||||
|
||||
export interface ThreadChannel
|
||||
extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites' | 'guild_id'>>,
|
||||
Omit<TextBaseGuildChannel, 'edit' | 'parentId'> {}
|
||||
Omit<TextBaseGuildChannel, 'edit' | 'parentId'> {
|
||||
parentId: string;
|
||||
}
|
||||
@mix(TextBaseGuildChannel)
|
||||
export class ThreadChannel extends BaseChannel<
|
||||
ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread
|
||||
> {
|
||||
parentId!: string;
|
||||
declare type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
|
||||
|
||||
webhooks = WebhookChannelMethods.channel({
|
||||
client: this.client,
|
||||
channelId: this.parentId,
|
||||
|
@ -1,43 +1,43 @@
|
||||
import type { Awaitable } from '../../common';
|
||||
|
||||
export type WorkerHeartbeaterMessages = SendHeartbeat;
|
||||
|
||||
export type CreateHeartbeaterMessage<T extends string, D extends object = object> = { type: T } & D;
|
||||
|
||||
export type SendHeartbeat = CreateHeartbeaterMessage<'HEARTBEAT'>;
|
||||
|
||||
export class Heartbeater {
|
||||
store = new Map<
|
||||
number,
|
||||
{
|
||||
ack: boolean;
|
||||
interval: NodeJS.Timeout;
|
||||
}
|
||||
>();
|
||||
constructor(
|
||||
public sendMethod: (workerId: number, data: WorkerHeartbeaterMessages) => Awaitable<void>,
|
||||
public interval: number,
|
||||
) {}
|
||||
|
||||
register(workerId: number, recreate: (workerId: number) => Awaitable<void>) {
|
||||
if (this.interval <= 0) return;
|
||||
this.store.set(workerId, {
|
||||
ack: true,
|
||||
interval: setInterval(() => {
|
||||
const heartbeat = this.store.get(workerId)!;
|
||||
if (!heartbeat.ack) {
|
||||
heartbeat.ack = true;
|
||||
return recreate(workerId);
|
||||
}
|
||||
heartbeat.ack = false;
|
||||
this.sendMethod(workerId, { type: 'HEARTBEAT' });
|
||||
}, this.interval),
|
||||
});
|
||||
}
|
||||
|
||||
acknowledge(workerId: number) {
|
||||
const heartbeat = this.store.get(workerId);
|
||||
if (!heartbeat) return;
|
||||
heartbeat.ack = true;
|
||||
}
|
||||
}
|
||||
import type { Awaitable } from '../../common';
|
||||
|
||||
export type WorkerHeartbeaterMessages = SendHeartbeat;
|
||||
|
||||
export type CreateHeartbeaterMessage<T extends string, D extends object = object> = { type: T } & D;
|
||||
|
||||
export type SendHeartbeat = CreateHeartbeaterMessage<'HEARTBEAT'>;
|
||||
|
||||
export class Heartbeater {
|
||||
store = new Map<
|
||||
number,
|
||||
{
|
||||
ack: boolean;
|
||||
interval: NodeJS.Timeout;
|
||||
}
|
||||
>();
|
||||
constructor(
|
||||
public sendMethod: (workerId: number, data: WorkerHeartbeaterMessages) => Awaitable<void>,
|
||||
public interval: number,
|
||||
) {}
|
||||
|
||||
register(workerId: number, recreate: (workerId: number) => Awaitable<void>) {
|
||||
if (this.interval <= 0) return;
|
||||
this.store.set(workerId, {
|
||||
ack: true,
|
||||
interval: setInterval(() => {
|
||||
const heartbeat = this.store.get(workerId)!;
|
||||
if (!heartbeat.ack) {
|
||||
heartbeat.ack = true;
|
||||
return recreate(workerId);
|
||||
}
|
||||
heartbeat.ack = false;
|
||||
this.sendMethod(workerId, { type: 'HEARTBEAT' });
|
||||
}, this.interval),
|
||||
});
|
||||
}
|
||||
|
||||
acknowledge(workerId: number) {
|
||||
const heartbeat = this.store.get(workerId);
|
||||
if (!heartbeat) return;
|
||||
heartbeat.ack = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user