Threads helpers

This commit is contained in:
TriForMine
2021-10-21 21:41:51 +02:00
parent 3a08aa15f4
commit 4a12b7714b
15 changed files with 124 additions and 150 deletions
+20 -17
View File
@@ -1,23 +1,26 @@
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";
import type { ModifyThread } from "../../../types/channels/threads/modify_thread.ts";
import type { Bot } from "../../../bot.ts";
import {channelToThread} from "../../../util/transformers/channel_to_thread.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);
export async function editThread(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) {
// const thread = await cacheHandlers.get("threads", threadId);
// TODO: permission checking
// TODO: permission checking
const result = await rest.runMethod(
"patch",
endpoints.CHANNEL_BASE(threadId),
snakelize({
...options,
reason,
})
);
const result = await bot.rest.runMethod(
bot.rest,
"patch",
bot.constants.endpoints.CHANNEL_BASE(threadId),
{
name: options.name,
archived: options.archived,
auto_archive_duration: options.autoArchiveDuration,
locked: options.locked,
rate_limit_per_user: options.rateLimitPerUser,
reason,
}
);
return channelToThread(result);
return channelToThread(result);
}