diff --git a/src/helpers/channels/clone_channel.ts b/src/helpers/channels/clone_channel.ts index 21524b143..d87d48682 100644 --- a/src/helpers/channels/clone_channel.ts +++ b/src/helpers/channels/clone_channel.ts @@ -1,24 +1,22 @@ import { cacheHandlers } from "../../cache.ts"; import { createChannel } from "./create_channel.ts"; -import { CreateGuildChannel } from "../../types/guilds/create_guild_channel.ts"; -import { DiscordenoChannel } from "../../structures/channel.ts"; +import { Errors } from "../../types/misc/errors.ts"; +import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; /** Create a copy of a channel */ export async function cloneChannel(channelId: string, reason?: string) { - const channelToClone = await cacheHandlers.get( - "channels", - channelId - ); - //Return undefined if channel is not cached (unsure about error handling) + const channelToClone = await cacheHandlers.get("channels", channelId); + //Return undefined if channel is not cached if (!channelToClone) throw new Error(Errors.CHANNEL_NOT_FOUND); - //If "name" is undefined as specified by types - channelToClone.name ??= "new-channel"; + //Check for DM channel + if ( + channelToClone.type === DiscordChannelTypes.DM || + channelToClone.type === DiscordChannelTypes.GROUP_DM + ) { + throw new Error(Errors.CHANNEL_NOT_IN_GUILD); + } //Create the channel (also handles permissions) - return createChannel( - channelToClone.guildId!, - channelToClone, - reason, - ); + return createChannel(channelToClone.guildId!, channelToClone, reason); }