mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
fixes
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
export * from "./add_to_thread.ts";
|
||||
export * from "./archive_thread.ts";
|
||||
export * from "./delete_thread.ts";
|
||||
export * from "./edit_thread.ts";
|
||||
export * from "./get_active_threads.ts";
|
||||
export * from "./get_archived_threads.ts";
|
||||
export * from "./get_thread_members.ts";
|
||||
export * from "./join_thread.ts";
|
||||
export * from "./leave_thread.ts";
|
||||
export * from "./lock_thread.ts";
|
||||
export * from "./remove_thread_member.ts";
|
||||
export * from "./start_private_thread.ts";
|
||||
export * from "./start_thread.ts";
|
||||
export * from "./unarchive_thread.ts";
|
||||
export * from "./unlock_thread.ts";
|
||||
@@ -136,6 +136,22 @@ import { deleteStageInstance } from "./channels/delete_stage_instance.ts";
|
||||
import { isSlashCommand } from "./type_guards/is_slash_command.ts";
|
||||
import { connectToVoiceChannel } from "./voice/connect_to_voice_channel.ts";
|
||||
|
||||
import { addToThread } from "./channels/threads/add_to_thread.ts";
|
||||
import { archiveThread } from "./channels/threads/archive_thread.ts";
|
||||
import { deleteThread } from "./channels/threads/delete_thread.ts";
|
||||
import { editThread } from "./channels/threads/edit_thread.ts";
|
||||
import { getActiveThreads } from "./channels/threads/get_active_threads.ts";
|
||||
import { getArchivedThreads } from "./channels/threads/get_archived_threads.ts";
|
||||
import { getThreadMembers } from "./channels/threads/get_thread_members.ts";
|
||||
import { joinThread } from "./channels/threads/join_thread.ts";
|
||||
import { leaveThread } from "./channels/threads/leave_thread.ts";
|
||||
import { lockThread } from "./channels/threads/lock_thread.ts";
|
||||
import { removeThreadMember } from "./channels/threads/remove_thread_member.ts";
|
||||
import { startPrivateThread } from "./channels/threads/start_private_thread.ts";
|
||||
import { startThread } from "./channels/threads/start_thread.ts";
|
||||
import { unarchiveThread } from "./channels/threads/unarchive_thread.ts";
|
||||
import { unlockThread } from "./channels/threads/unlock_thread.ts";
|
||||
|
||||
export {
|
||||
addDiscoverySubcategory,
|
||||
addReaction,
|
||||
@@ -276,6 +292,21 @@ export {
|
||||
upsertSlashCommand,
|
||||
upsertSlashCommands,
|
||||
validDiscoveryTerm,
|
||||
addToThread,
|
||||
archiveThread,
|
||||
deleteThread,
|
||||
editThread,
|
||||
getActiveThreads,
|
||||
getArchivedThreads,
|
||||
getThreadMembers,
|
||||
joinThread,
|
||||
leaveThread,
|
||||
lockThread,
|
||||
removeThreadMember,
|
||||
startPrivateThread,
|
||||
startThread,
|
||||
unarchiveThread,
|
||||
unlockThread,
|
||||
};
|
||||
|
||||
export let helpers = {
|
||||
@@ -424,6 +455,22 @@ export let helpers = {
|
||||
getWebhook,
|
||||
getWebhooks,
|
||||
getWebhookMessage,
|
||||
// threads
|
||||
addToThread,
|
||||
archiveThread,
|
||||
deleteThread,
|
||||
editThread,
|
||||
getActiveThreads,
|
||||
getArchivedThreads,
|
||||
getThreadMembers,
|
||||
joinThread,
|
||||
leaveThread,
|
||||
lockThread,
|
||||
removeThreadMember,
|
||||
startPrivateThread,
|
||||
startThread,
|
||||
unarchiveThread,
|
||||
unlockThread,
|
||||
};
|
||||
|
||||
export type Helpers = typeof helpers;
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { Message } from "../types/messages/message.ts";
|
||||
import { bigintToSnowflake, snowflakeToBigint } from "../util/bigint.ts";
|
||||
import { CHANNEL_MENTION_REGEX } from "../util/constants.ts";
|
||||
import { iconBigintToHash } from "../util/hash.ts";
|
||||
import { channelToThread, DiscordenoThread } from "../util/transformers/channel_to_thread.ts";
|
||||
import { createNewProp } from "../util/utils.ts";
|
||||
import { DiscordenoChannel } from "./channel.ts";
|
||||
import { DiscordenoGuild } from "./guild.ts";
|
||||
@@ -144,6 +145,9 @@ const baseMessage: Partial<DiscordenoMessage> = {
|
||||
get pinned() {
|
||||
return Boolean(this.bitfield! & messageToggles.pinned);
|
||||
},
|
||||
get thread() {
|
||||
return cache.threads.get(this.id!);
|
||||
},
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id?.toString(),
|
||||
@@ -219,13 +223,16 @@ export async function createDiscordenoMessage(data: Message) {
|
||||
}
|
||||
|
||||
// Don't add member to props since it would overwrite the message.member getter
|
||||
if (key === "member") return;
|
||||
// thread should not be cached on a message
|
||||
if (["member", "thread"].includes(key)) return;
|
||||
|
||||
props[key] = createNewProp(
|
||||
MESSAGE_SNOWFLAKES.includes(key) ? (rest[key] ? snowflakeToBigint(rest[key] as string) : undefined) : rest[key]
|
||||
);
|
||||
});
|
||||
|
||||
if (rest.thread) await cacheHandlers.set("threads", snowflakeToBigint(data.id), channelToThread(rest.thread));
|
||||
|
||||
props.authorId = createNewProp(snowflakeToBigint(author.id));
|
||||
props.isBot = createNewProp(author.bot || false);
|
||||
props.tag = createNewProp(`${author.username}#${author.discriminator.toString().padStart(4, "0")}`);
|
||||
@@ -280,6 +287,7 @@ export interface DiscordenoMessage
|
||||
| "member"
|
||||
| "author"
|
||||
| "applicationId"
|
||||
| "thread"
|
||||
> {
|
||||
id: bigint;
|
||||
/** Whether or not this message was sent by a bot */
|
||||
@@ -336,6 +344,8 @@ export interface DiscordenoMessage
|
||||
mentionedChannels: (DiscordenoChannel | undefined)[];
|
||||
/** The member objects for all the members that were mentioned in this message. */
|
||||
mentionedMembers: (DiscordenoMember | undefined)[];
|
||||
/** The thread if this message has a thread. */
|
||||
thread?: DiscordenoThread;
|
||||
|
||||
// METHODS
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ export interface ThreadMemberBase {
|
||||
flags: number;
|
||||
}
|
||||
|
||||
export interface ThreadMemberOnGuildCreate extends ThreadMemberBase {
|
||||
/** The time the current user last joined the thread */
|
||||
joinTimestamp: string;
|
||||
}
|
||||
|
||||
export interface ThreadMember extends ThreadMemberBase {
|
||||
/** The id of the thread */
|
||||
id?: string;
|
||||
|
||||
Reference in New Issue
Block a user