mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
fix: bad channel.thread handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { editChannel } from "../edit_channel.ts";
|
||||
import { editThread } from "./edit_thread.ts";
|
||||
|
||||
/** Sets a thread channel to be archived. */
|
||||
export function archiveThread(threadId: bigint) {
|
||||
return editChannel(threadId, { archived: true });
|
||||
return editThread(threadId, { archived: true });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { cacheHandlers } from "../../../cache.ts";
|
||||
import { rest } from "../../../rest/rest.ts";
|
||||
import { endpoints } from "../../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../../util/permissions.ts";
|
||||
|
||||
/** Delete a thread in your server. Bot needs MANAGE_THREADS permissions in the server. */
|
||||
export async function deleteThread(threadId: bigint, reason?: string) {
|
||||
const thread = await cacheHandlers.get("threads", threadId);
|
||||
if (thread) {
|
||||
const channel = await cacheHandlers.get("channels", thread?.channelId);
|
||||
if (channel?.guildId) await requireBotGuildPermissions(channel.guildId, ["MANAGE_THREADS"]);
|
||||
}
|
||||
|
||||
return await rest.runMethod("delete", endpoints.CHANNEL_BASE(threadId), { reason });
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { rest } from "../../../rest/rest.ts";
|
||||
import { ModifyThread } from "../../../types/channels/threads/modify_thread.ts";
|
||||
import { endpoints } from "../../../util/constants.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { snakelize } from "../../../util/utils.ts";
|
||||
|
||||
/** Update a thread's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */
|
||||
export async function editThread(threadId: bigint, options: ModifyThread, reason?: string) {
|
||||
// const thread = await cacheHandlers.get("threads", threadId);
|
||||
|
||||
const result = await rest.runMethod(
|
||||
"patch",
|
||||
endpoints.CHANNEL_BASE(threadId),
|
||||
snakelize({
|
||||
...options,
|
||||
reason,
|
||||
})
|
||||
);
|
||||
|
||||
return channelToThread(result);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { editChannel } from "../edit_channel.ts";
|
||||
import { editThread } from "./edit_thread.ts";
|
||||
|
||||
/** Sets a thread channel to be locked. */
|
||||
export function lockThread(threadId: bigint) {
|
||||
return editChannel(threadId, { locked: true });
|
||||
return editThread(threadId, { locked: true });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { editChannel } from "../edit_channel.ts";
|
||||
import { editThread } from "./edit_thread.ts";
|
||||
|
||||
/** Sets a thread channel to be unarchived. */
|
||||
export function unarchiveThread(threadId: bigint) {
|
||||
return editChannel(threadId, { archived: false });
|
||||
return editThread(threadId, { archived: false });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { editChannel } from "../edit_channel.ts";
|
||||
import { editThread } from "./edit_thread.ts";
|
||||
|
||||
/** Sets a thread channel to be unlocked. */
|
||||
export function unlockThread(threadId: bigint) {
|
||||
return editChannel(threadId, { locked: false });
|
||||
return editThread(threadId, { locked: false });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user