more thread fixes

This commit is contained in:
Skillz4Killz
2021-06-13 20:45:47 +00:00
committed by GitHub
parent 37d3952559
commit 950482c503
11 changed files with 51 additions and 20 deletions
@@ -0,0 +1,20 @@
import { Channel } from "../../types/channels/channel.ts";
import { snowflakeToBigint } from "../bigint.ts";
export function channelToThread(channel: Channel) {
return {
id: snowflakeToBigint(channel.id),
channelId: snowflakeToBigint(channel.parentId!),
memberCount: channel.memberCount,
messageCount: channel.messageCount,
archived: channel.threadMetadata?.archived || false,
archiveTimestamp: channel.threadMetadata?.archiveTimestamp
? Date.parse(channel.threadMetadata.archiveTimestamp)
: undefined,
archiverId: channel.threadMetadata?.archiverId ? snowflakeToBigint(channel.threadMetadata.archiverId) : undefined,
autoArchiveDuration: channel.threadMetadata?.autoArchiveDuration || 0,
locked: channel.threadMetadata?.locked || false,
};
}
export type Thread = ReturnType<typeof channelToThread>;
+2
View File
@@ -0,0 +1,2 @@
export * from "./channel_to_thread.ts";
export * from "./thread_member_modified.ts";
@@ -0,0 +1,11 @@
import { ThreadMember, ThreadMemberModified } from "../../types/channels/threads/thread_member.ts";
import { snowflakeToBigint } from "../bigint.ts";
export function threadMemberModified(member: ThreadMember) {
return {
...member,
id: snowflakeToBigint(member.id),
userId: snowflakeToBigint(member.userId),
joinTimestamp: Date.parse(member.joinTimestamp),
} as ThreadMemberModified;
}