fix: thread.channelId -> thread.parentId

This commit is contained in:
Skillz4Killz
2021-06-19 14:34:52 +00:00
committed by GitHub
parent 805a1aed12
commit 15801c214b
5 changed files with 8 additions and 8 deletions
@@ -14,7 +14,7 @@ export async function addToThread(threadId: bigint, userId: bigint) {
} }
// If a user id is provided SEND_MESSAGES is required. // If a user id is provided SEND_MESSAGES is required.
const channel = await cacheHandlers.get("channels", thread.channelId); const channel = await cacheHandlers.get("channels", thread.parentId);
// TODO: does MANAGE_THREADS override this???? // TODO: does MANAGE_THREADS override this????
if (channel) await requireBotChannelPermissions(channel, ["SEND_MESSAGES"]); if (channel) await requireBotChannelPermissions(channel, ["SEND_MESSAGES"]);
} }
@@ -7,7 +7,7 @@ import { requireBotGuildPermissions } from "../../../util/permissions.ts";
export async function deleteThread(threadId: bigint, reason?: string) { export async function deleteThread(threadId: bigint, reason?: string) {
const thread = await cacheHandlers.get("threads", threadId); const thread = await cacheHandlers.get("threads", threadId);
if (thread) { if (thread) {
const channel = await cacheHandlers.get("channels", thread?.channelId); const channel = await cacheHandlers.get("channels", thread?.parentId);
if (channel?.guildId) await requireBotGuildPermissions(channel.guildId, ["MANAGE_THREADS"]); if (channel?.guildId) await requireBotGuildPermissions(channel.guildId, ["MANAGE_THREADS"]);
} }
@@ -15,7 +15,7 @@ export async function getThreadMembers(threadId: bigint) {
const thread = await cacheHandlers.get("threads", threadId); const thread = await cacheHandlers.get("threads", threadId);
if (thread?.isPrivate) { if (thread?.isPrivate) {
const channel = await cacheHandlers.get("channels", thread.channelId); const channel = await cacheHandlers.get("channels", thread.parentId);
if (channel && !(await botHasChannelPermissions(channel, ["MANAGE_THREADS"])) && !thread.botIsMember) if (channel && !(await botHasChannelPermissions(channel, ["MANAGE_THREADS"])) && !thread.botIsMember)
throw new Error(Errors.CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD); throw new Error(Errors.CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD);
} }
@@ -12,7 +12,7 @@ export async function removeThreadMember(threadId: bigint, userId: bigint) {
if (thread.archived) throw new Error(Errors.CANNOT_REMOVE_FROM_ARCHIVED_THREAD); if (thread.archived) throw new Error(Errors.CANNOT_REMOVE_FROM_ARCHIVED_THREAD);
if (thread.ownerId !== botId) { if (thread.ownerId !== botId) {
const channel = await cacheHandlers.get("channels", thread.channelId); const channel = await cacheHandlers.get("channels", thread.parentId);
if (channel) await requireBotChannelPermissions(channel, ["MANAGE_THREADS"]); if (channel) await requireBotChannelPermissions(channel, ["MANAGE_THREADS"]);
} }
} }
+4 -4
View File
@@ -29,7 +29,7 @@ const baseThread: Partial<DiscordenoThread> = {
return { return {
id: this.id?.toString(), id: this.id?.toString(),
type: this.type, type: this.type,
channelId: this.channelId?.toString(), parentId: this.parentId?.toString(),
memberCount: this.memberCount, memberCount: this.memberCount,
messageCount: this.messageCount, messageCount: this.messageCount,
archiveTimestamp: new Date(this.archiveTimestamp!).toISOString(), archiveTimestamp: new Date(this.archiveTimestamp!).toISOString(),
@@ -49,7 +49,7 @@ export function channelToThread(channel: Channel) {
return Object.create(baseThread, { return Object.create(baseThread, {
id: createNewProp(snowflakeToBigint(channel.id)), id: createNewProp(snowflakeToBigint(channel.id)),
type: createNewProp(channel.type), type: createNewProp(channel.type),
channelId: createNewProp(snowflakeToBigint(channel.parentId!)), parentId: createNewProp(snowflakeToBigint(channel.parentId!)),
memberCount: createNewProp(channel.memberCount), memberCount: createNewProp(channel.memberCount),
messageCount: createNewProp(channel.messageCount), messageCount: createNewProp(channel.messageCount),
archiveTimestamp: createNewProp( archiveTimestamp: createNewProp(
@@ -69,7 +69,7 @@ export interface Thread {
| DiscordChannelTypes.GuildNewsThread | DiscordChannelTypes.GuildNewsThread
| DiscordChannelTypes.GuildPublicThread | DiscordChannelTypes.GuildPublicThread
| DiscordChannelTypes.GuildPrivateThread; | DiscordChannelTypes.GuildPrivateThread;
channelId: string; parentId: string;
memberCount: number; memberCount: number;
messageCount: number; messageCount: number;
archiveTimestamp: string; archiveTimestamp: string;
@@ -86,7 +86,7 @@ export interface DiscordenoThread {
| DiscordChannelTypes.GuildNewsThread | DiscordChannelTypes.GuildNewsThread
| DiscordChannelTypes.GuildPublicThread | DiscordChannelTypes.GuildPublicThread
| DiscordChannelTypes.GuildPrivateThread; | DiscordChannelTypes.GuildPrivateThread;
channelId: bigint; parentId: bigint;
memberCount: number; memberCount: number;
messageCount: number; messageCount: number;
archiveTimestamp: number; archiveTimestamp: number;