fix: move editThread to helpers plugin

This commit is contained in:
Skillz4Killz
2021-12-03 16:17:39 +00:00
committed by GitHub
parent 7c171faf3c
commit 1464eb0c75
5 changed files with 11 additions and 33 deletions

View File

@@ -1,21 +0,0 @@
import type { ModifyThread } from "../../../types/channels/threads/modifyThread.ts";
import type { Bot } from "../../../bot.ts";
import { Channel } from "../../../types/channels/channel.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(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) {
const result = await bot.rest.runMethod<Channel>(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 bot.transformers.channel(bot, {
channel: result,
guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined,
});
}

View File

@@ -1,5 +1,4 @@
export * from "./addToThread.ts";
export * from "./editThread.ts";
export * from "./getActiveThreads.ts";
export * from "./getArchivedThreads.ts";
export * from "./getThreadMembers.ts";

View File

@@ -159,7 +159,6 @@ export * from "./channels/getStageInstance.ts";
export * from "./channels/deleteStageInstance.ts";
export * from "./voice/connectToVoiceChannel.ts";
export * from "./channels/threads/addToThread.ts";
export * from "./channels/threads/editThread.ts";
export * from "./channels/threads/getActiveThreads.ts";
export * from "./channels/threads/getArchivedThreads.ts";
export * from "./channels/threads/getThreadMember.ts";

View File

@@ -1,6 +1,5 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { ChannelTypes } from "./channelTypes.ts";
import { DiscordOverwrite, Overwrite } from "./overwrite.ts";
import { Overwrite } from "./overwrite.ts";
import { VideoQualityModes } from "./videoQualityModes.ts";
export interface ModifyChannel {
@@ -28,10 +27,12 @@ export interface ModifyChannel {
rtcRegion?: string | null;
/** The camera video quality mode of the voice channel */
videoQualityMode?: VideoQualityModes;
}
/** https://discord.com/developers/docs/resources/channel#modify-channel */
export interface DiscordModifyChannel extends SnakeCasedPropertiesDeep<Omit<ModifyChannel, "permissionOverwrites">> {
// deno-lint-ignore camelcase
permission_overwrites?: DiscordOverwrite[];
/** Whether the thread is archived */
archived?: boolean;
/** Duration in minutes to automatically archive the thread after recent activity */
autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
locked?: boolean;
/** whether non-moderators can add other non-moderators to a thread; only available on private threads */
invitable?: boolean;
}

View File

@@ -1,4 +1,4 @@
import { assertEquals, assertExists, assertNotEquals, assertThrows } from "../deps.ts";
import { assertEquals, assertExists, assertNotEquals } from "../deps.ts";
import { bot, guild } from "../mod.ts";
Deno.test("[thread] Start a thread", async (t) => {
@@ -34,7 +34,7 @@ Deno.test("[thread] Start a thread", async (t) => {
assertEquals(archived.members.size, 0);
await t.step("[thread] Edit and archive a thread", async () => {
const edited = await bot.helpers.editThread(thread.id, {
const edited = await bot.helpers.editChannel(thread.id, {
archived: true,
name: "new name",
autoArchiveDuration: 1440,