diff --git a/src/helpers/channels/cloneChannel.ts b/src/helpers/channels/cloneChannel.ts deleted file mode 100644 index 5eb14825a..000000000 --- a/src/helpers/channels/cloneChannel.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Bot } from "../../bot.ts"; -import { DiscordenoChannel, separateOverwrites } from "../../transformers/channel.ts"; -import type { CreateGuildChannel } from "../../types/guilds/createGuildChannel.ts"; - -/** Create a copy of a channel */ -export async function cloneChannel(bot: Bot, channel: DiscordenoChannel, reason?: string) { - if (!channel.guildId) throw new Error(`Cannot clone a channel outside a guild`); - - const createChannelOptions: CreateGuildChannel = { - type: channel.type, - bitrate: channel.bitrate, - userLimit: channel.userLimit, - rateLimitPerUser: channel.rateLimitPerUser, - position: channel.position, - parentId: channel.parentId, - nsfw: channel.nsfw, - name: channel.name!, - topic: channel.topic || undefined, - permissionOverwrites: channel.permissionOverwrites.map((overwrite) => { - const [type, id, allow, deny] = separateOverwrites(overwrite); - - return { - id, - type, - allow: bot.utils.calculatePermissions(BigInt(allow)), - deny: bot.utils.calculatePermissions(BigInt(deny)), - }; - }), - }; - - //Create the channel (also handles permissions) - return await bot.helpers.createChannel(channel.guildId!, createChannelOptions, reason); -} diff --git a/src/helpers/mod.ts b/src/helpers/mod.ts index bddb7a8dc..0b9dd2b0e 100644 --- a/src/helpers/mod.ts +++ b/src/helpers/mod.ts @@ -169,7 +169,6 @@ export * from "./channels/threads/leaveThread.ts"; export * from "./channels/threads/removeThreadMember.ts"; export * from "./channels/threads/startThreadWithMessage.ts"; export * from "./channels/threads/startThreadWithoutMessage.ts"; -export * from "./channels/cloneChannel.ts"; //guilds export * from "./guilds/scheduledEvents/createScheduledEvent.ts"; diff --git a/tests/helpers/channels/cloneChannel.ts b/tests/helpers/channels/cloneChannel.ts deleted file mode 100644 index 9ecaff3d0..000000000 --- a/tests/helpers/channels/cloneChannel.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { DiscordenoChannel } from "../../../src/transformers/channel.ts"; -import { assertExists, assertEquals } from "../../deps.ts"; -import { bot, channel } from "../../mod.ts"; -import { delayUntil } from "../../utils.ts"; - -export async function cloneChannelTests( - options: { reason?: string }, -) { - // @ts-ignore for itoh - const cloned = await bot.helpers.cloneChannel(channel, options.reason); - - //Assertations - assertExists(cloned); - assertEquals(cloned.type, channel.type); - - // Delay the execution to allow CHANNEL_CREATE event to be processed - await delayUntil(10000, () => bot.channels.has(cloned.id)); - - assertExists(bot.channels.has(cloned.id)); - assertEquals(channel.topic, cloned.topic); - assertEquals(channel.bitrate, cloned.bitrate); - assertEquals(channel.permissionOverwrites.length, cloned.permissionOverwrites.length); -} diff --git a/tests/mod.ts b/tests/mod.ts index 8c4ba289a..8aeda3cc7 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -31,7 +31,6 @@ import { getGuildTests } from "./helpers/guilds/getGuild.ts"; import { getVanityURLTests } from "./helpers/guilds/getVanityUrl.ts"; import { categoryChildrenTest } from "./helpers/channels/categoryChannels.ts"; import { channelOverwriteHasPermissionTest } from "./helpers/channels/channelOverwriteHasPermission.ts"; -import { cloneChannelTests } from "./helpers/channels/cloneChannel.ts"; import { deleteChannelOverwriteTests } from "./helpers/channels/deleteChannelOverwrite.ts"; import { editChannelTests } from "./helpers/channels/editChannel.ts"; import { CACHED_COMMUNITY_GUILD_ID, sanitizeMode } from "./constants.ts"; @@ -275,20 +274,6 @@ Deno.test({ }, ...sanitizeMode, }); -Deno.test({ - name: "[channel] clone a channel w/o a reason", - async fn(t) { - await cloneChannelTests({}); - }, - ...sanitizeMode, -}); -Deno.test({ - name: "[channel] clone a channel w/ a reason", - async fn(t) { - await cloneChannelTests({ reason: "Blame wolf" }); - }, - ...sanitizeMode, -}); Deno.test({ name: "[channel] delete a channel overwrite", async fn(t) {