mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
fix: thread errors and typings in cache
This commit is contained in:
14
src/cache.ts
14
src/cache.ts
@@ -6,7 +6,7 @@ import type { DiscordenoMember } from "./structures/member.ts";
|
||||
import type { DiscordenoMessage } from "./structures/message.ts";
|
||||
import type { PresenceUpdate } from "./types/activity/presence_update.ts";
|
||||
import type { Emoji } from "./types/emojis/emoji.ts";
|
||||
import { Thread } from "./util/transformers/channel_to_thread.ts";
|
||||
import { DiscordenoThread } from "./util/transformers/channel_to_thread.ts";
|
||||
import { Collection } from "./util/collection.ts";
|
||||
|
||||
export const cache = {
|
||||
@@ -36,7 +36,7 @@ export const cache = {
|
||||
activeGuildIds: new Set<bigint>(),
|
||||
dispatchedGuildIds: new Set<bigint>(),
|
||||
dispatchedChannelIds: new Set<bigint>(),
|
||||
threads: new Collection<bigint, Thread>(),
|
||||
threads: new Collection<bigint, DiscordenoThread>(),
|
||||
};
|
||||
|
||||
function messageSweeper(message: DiscordenoMessage) {
|
||||
@@ -111,7 +111,7 @@ export let cacheHandlers = {
|
||||
|
||||
export type TableName = "guilds" | "unavailableGuilds" | "channels" | "messages" | "members" | "presences" | "threads";
|
||||
|
||||
async function set(table: "threads", key: bigint, value: Thread): Promise<Collection<bigint, Thread>>;
|
||||
async function set(table: "threads", key: bigint, value: DiscordenoThread): Promise<Collection<bigint, DiscordenoThread>>;
|
||||
async function set(table: "guilds", key: bigint, value: DiscordenoGuild): Promise<Collection<bigint, DiscordenoGuild>>;
|
||||
async function set(
|
||||
table: "channels",
|
||||
@@ -134,7 +134,7 @@ async function set(table: TableName, key: bigint, value: any) {
|
||||
return cache[table].set(key, value);
|
||||
}
|
||||
|
||||
async function get(table: "threads", key: bigint): Promise<Thread | undefined>;
|
||||
async function get(table: "threads", key: bigint): Promise<DiscordenoThread | undefined>;
|
||||
async function get(table: "guilds", key: bigint): Promise<DiscordenoGuild | undefined>;
|
||||
async function get(table: "channels", key: bigint): Promise<DiscordenoChannel | undefined>;
|
||||
async function get(table: "messages", key: bigint): Promise<DiscordenoMessage | undefined>;
|
||||
@@ -145,7 +145,7 @@ async function get(table: TableName, key: bigint) {
|
||||
return cache[table].get(key);
|
||||
}
|
||||
|
||||
function forEach(table: "threads", callback: (value: Thread, key: bigint, map: Map<bigint, Thread>) => unknown): void;
|
||||
function forEach(table: "threads", callback: (value: DiscordenoThread, key: bigint, map: Map<bigint, DiscordenoThread>) => unknown): void;
|
||||
function forEach(
|
||||
table: "guilds",
|
||||
callback: (value: DiscordenoGuild, key: bigint, map: Map<bigint, DiscordenoGuild>) => unknown
|
||||
@@ -172,8 +172,8 @@ function forEach(table: TableName, callback: (value: any, key: bigint, map: Map<
|
||||
|
||||
async function filter(
|
||||
table: "threads",
|
||||
callback: (value: Thread, key: bigint) => boolean
|
||||
): Promise<Collection<bigint, Thread>>;
|
||||
callback: (value: DiscordenoThread, key: bigint) => boolean
|
||||
): Promise<Collection<bigint, DiscordenoThread>>;
|
||||
async function filter(
|
||||
table: "guilds",
|
||||
callback: (value: DiscordenoGuild, key: bigint) => boolean
|
||||
|
||||
@@ -24,7 +24,7 @@ export enum Errors {
|
||||
INVALID_THREAD_PARENT_CHANNEL_TYPE = "INVALID_THREAD_PARENT_CHANNEL_TYPE",
|
||||
GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS = "GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS",
|
||||
NOT_A_THREAD_CHANNEL = "NOT_A_THREAD_CHANNEL",
|
||||
HAVE_TO_BE_PART_OF_THE_THREAD_OR_A_THREAD_MODERATOR_TO_ADD_OTHERS_TO_A_THREAD = "HAVE_TO_BE_PART_OF_THE_THREAD_OR_A_THREAD_MODERATOR_TO_ADD_OTHERS_TO_A_THREAD",
|
||||
MISSING_MANAGE_THREADS_AND_NOT_MEMBER = "MISSING_MANAGE_THREADS_AND_NOT_MEMBER",
|
||||
CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD = "CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD",
|
||||
HAVE_TO_BE_THE_CREATOR_OF_THE_THREAD_OR_HAVE_MANAGE_THREADS_TO_REMOVE_MEMBERS = "HAVE_TO_BE_THE_CREATOR_OF_THE_THREAD_OR_HAVE_MANAGE_THREADS_TO_REMOVE_MEMBERS",
|
||||
// Message Get Errors
|
||||
@@ -113,4 +113,5 @@ export enum Errors {
|
||||
SELECT_OPTION_VALUE_TOO_BIG = "SELECT_OPTION_VALUE_TOO_BIG",
|
||||
SELECT_OPTION_TOO_MANY_DEFAULTS = "SELECT_OPTION_TOO_MANY_DEFAULTS",
|
||||
COMPONENT_SELECT_MIN_HIGHER_THAN_MAX = "COMPONENT_SELECT_MIN_HIGHER_THAN_MAX",
|
||||
CANNOT_ADD_USER_TO_ARCHIVED_THREADS = "CANNOT_ADD_USER_TO_ARCHIVED_THREADS",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user