Files
discordeno/src/helpers/channels/clone_channel.ts
T
2021-04-14 08:47:21 -04:00

25 lines
781 B
TypeScript

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";
/** 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)
if (!channelToClone) return;
//If "name" is undefined as specified by types
channelToClone.name ??= "new-channel";
//Create the channel (also handles permissions)
return createChannel(
channelToClone.guildId!,
channelToClone,
reason,
);
}