mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
fix: more bugs bugs bugs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Channel } from "../../types/channels/channel.ts";
|
||||
import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { snowflakeToBigint } from "../bigint.ts";
|
||||
import { createNewProp } from "../utils.ts";
|
||||
|
||||
@@ -16,9 +17,16 @@ const baseThread: Partial<DiscordenoThread> = {
|
||||
get locked() {
|
||||
return Boolean(this.bitfield! & threadToggles.locked);
|
||||
},
|
||||
get isPrivate() {
|
||||
return this.type === DiscordChannelTypes.GuildPrivateThread;
|
||||
},
|
||||
get isPublic() {
|
||||
return !this.isPrivate;
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id?.toString(),
|
||||
type: this.type,
|
||||
channelId: this.channelId?.toString(),
|
||||
memberCount: this.memberCount,
|
||||
messageCount: this.messageCount,
|
||||
@@ -39,6 +47,7 @@ export function channelToThread(channel: Channel) {
|
||||
|
||||
return Object.create(baseThread, {
|
||||
id: createNewProp(snowflakeToBigint(channel.id)),
|
||||
type: createNewProp(channel.type),
|
||||
channelId: createNewProp(snowflakeToBigint(channel.parentId!)),
|
||||
memberCount: createNewProp(channel.memberCount),
|
||||
messageCount: createNewProp(channel.messageCount),
|
||||
@@ -50,12 +59,17 @@ export function channelToThread(channel: Channel) {
|
||||
),
|
||||
autoArchiveDuration: createNewProp(channel.threadMetadata?.autoArchiveDuration || 0),
|
||||
bitfield: createNewProp(bitfield),
|
||||
ownerId: createNewProp(snowflakeToBigint(channel.ownerId!))
|
||||
ownerId: createNewProp(snowflakeToBigint(channel.ownerId!)),
|
||||
botIsMember: createNewProp(Boolean(channel.member))
|
||||
});
|
||||
}
|
||||
|
||||
export interface Thread {
|
||||
id: string;
|
||||
type:
|
||||
| DiscordChannelTypes.GuildNewsThread
|
||||
| DiscordChannelTypes.GuildPublicThread
|
||||
| DiscordChannelTypes.GuildPrivateThread;
|
||||
channelId: string;
|
||||
memberCount: number;
|
||||
messageCount: number;
|
||||
@@ -65,10 +79,15 @@ export interface Thread {
|
||||
archived: boolean;
|
||||
locked: boolean;
|
||||
ownerId: string;
|
||||
botIsMember: boolean;
|
||||
}
|
||||
|
||||
export interface DiscordenoThread {
|
||||
id: bigint;
|
||||
type:
|
||||
| DiscordChannelTypes.GuildNewsThread
|
||||
| DiscordChannelTypes.GuildPublicThread
|
||||
| DiscordChannelTypes.GuildPrivateThread;
|
||||
channelId: bigint;
|
||||
memberCount: number;
|
||||
messageCount: number;
|
||||
@@ -79,5 +98,8 @@ export interface DiscordenoThread {
|
||||
locked: boolean;
|
||||
bitfield: bigint;
|
||||
ownerId: bigint;
|
||||
isPrivate: boolean;
|
||||
isPublic: boolean;
|
||||
botIsMember: boolean;
|
||||
toJSON(): Thread;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user