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
|
export interface ThreadChannel
|
||||||
extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites' | 'guild_id'>>,
|
extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites' | 'guild_id'>>,
|
||||||
Omit<TextBaseGuildChannel, 'edit' | 'parentId'> {}
|
Omit<TextBaseGuildChannel, 'edit' | 'parentId'> {
|
||||||
|
parentId: string;
|
||||||
|
}
|
||||||
@mix(TextBaseGuildChannel)
|
@mix(TextBaseGuildChannel)
|
||||||
export class ThreadChannel extends BaseChannel<
|
export class ThreadChannel extends BaseChannel<
|
||||||
ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread
|
ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread
|
||||||
> {
|
> {
|
||||||
parentId!: string;
|
|
||||||
declare type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
|
declare type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
|
||||||
|
|
||||||
webhooks = WebhookChannelMethods.channel({
|
webhooks = WebhookChannelMethods.channel({
|
||||||
client: this.client,
|
client: this.client,
|
||||||
channelId: this.parentId,
|
channelId: this.parentId,
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
import type { Awaitable } from '../../common';
|
import type { Awaitable } from '../../common';
|
||||||
|
|
||||||
export type WorkerHeartbeaterMessages = SendHeartbeat;
|
export type WorkerHeartbeaterMessages = SendHeartbeat;
|
||||||
|
|
||||||
export type CreateHeartbeaterMessage<T extends string, D extends object = object> = { type: T } & D;
|
export type CreateHeartbeaterMessage<T extends string, D extends object = object> = { type: T } & D;
|
||||||
|
|
||||||
export type SendHeartbeat = CreateHeartbeaterMessage<'HEARTBEAT'>;
|
export type SendHeartbeat = CreateHeartbeaterMessage<'HEARTBEAT'>;
|
||||||
|
|
||||||
export class Heartbeater {
|
export class Heartbeater {
|
||||||
store = new Map<
|
store = new Map<
|
||||||
number,
|
number,
|
||||||
{
|
{
|
||||||
ack: boolean;
|
ack: boolean;
|
||||||
interval: NodeJS.Timeout;
|
interval: NodeJS.Timeout;
|
||||||
}
|
}
|
||||||
>();
|
>();
|
||||||
constructor(
|
constructor(
|
||||||
public sendMethod: (workerId: number, data: WorkerHeartbeaterMessages) => Awaitable<void>,
|
public sendMethod: (workerId: number, data: WorkerHeartbeaterMessages) => Awaitable<void>,
|
||||||
public interval: number,
|
public interval: number,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
register(workerId: number, recreate: (workerId: number) => Awaitable<void>) {
|
register(workerId: number, recreate: (workerId: number) => Awaitable<void>) {
|
||||||
if (this.interval <= 0) return;
|
if (this.interval <= 0) return;
|
||||||
this.store.set(workerId, {
|
this.store.set(workerId, {
|
||||||
ack: true,
|
ack: true,
|
||||||
interval: setInterval(() => {
|
interval: setInterval(() => {
|
||||||
const heartbeat = this.store.get(workerId)!;
|
const heartbeat = this.store.get(workerId)!;
|
||||||
if (!heartbeat.ack) {
|
if (!heartbeat.ack) {
|
||||||
heartbeat.ack = true;
|
heartbeat.ack = true;
|
||||||
return recreate(workerId);
|
return recreate(workerId);
|
||||||
}
|
}
|
||||||
heartbeat.ack = false;
|
heartbeat.ack = false;
|
||||||
this.sendMethod(workerId, { type: 'HEARTBEAT' });
|
this.sendMethod(workerId, { type: 'HEARTBEAT' });
|
||||||
}, this.interval),
|
}, this.interval),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
acknowledge(workerId: number) {
|
acknowledge(workerId: number) {
|
||||||
const heartbeat = this.store.get(workerId);
|
const heartbeat = this.store.get(workerId);
|
||||||
if (!heartbeat) return;
|
if (!heartbeat) return;
|
||||||
heartbeat.ack = true;
|
heartbeat.ack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user