seyfert/src/events/hooks/thread.ts
MARCROCK22 13b8a32d42
fix rest types, collectors update, improve types (#266)
* feat: ctx types, delete threads cache, cache.channels.threads, changes to collectors, fix rest types

* fix: use apithreadchannel instead

* feat: revert threads relationship, fix collectors

* fix: cache thread when creating

* fix: unused

* feat: entitlement trasnformer

* fix: non-null assertion

* fix: circular?

* fix: collector onStop reason type

* fix: types

* feat: onPass method

* fix: undefined value
2024-09-27 22:08:50 -05:00

39 lines
1.4 KiB
TypeScript

import { type ThreadChannelStructure, Transformers } from '../../client/transformers';
import type { UsingClient } from '../../commands';
import { toCamelCase } from '../../common';
import type {
GatewayThreadCreateDispatchData,
GatewayThreadDeleteDispatchData,
GatewayThreadListSyncDispatchData,
GatewayThreadMemberUpdateDispatchData,
GatewayThreadMembersUpdateDispatchData,
GatewayThreadUpdateDispatchData,
} from '../../types';
export const THREAD_CREATE = (self: UsingClient, data: GatewayThreadCreateDispatchData) => {
return Transformers.ThreadChannel(self, data);
};
export const THREAD_DELETE = (self: UsingClient, data: GatewayThreadDeleteDispatchData) => {
return Transformers.ThreadChannel(self, data);
};
export const THREAD_LIST_SYNC = (_self: UsingClient, data: GatewayThreadListSyncDispatchData) => {
return toCamelCase(data);
};
export const THREAD_MEMBER_UPDATE = (_self: UsingClient, data: GatewayThreadMemberUpdateDispatchData) => {
return toCamelCase(data);
};
export const THREAD_MEMBERS_UPDATE = (_self: UsingClient, data: GatewayThreadMembersUpdateDispatchData) => {
return toCamelCase(data);
};
export const THREAD_UPDATE = async (
self: UsingClient,
data: GatewayThreadUpdateDispatchData,
): Promise<[thread: ThreadChannelStructure, old?: ThreadChannelStructure]> => {
return [Transformers.ThreadChannel(self, data), (await self.cache.channels?.get(data.id)) as ThreadChannelStructure];
};