mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
4183ffd21d
Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
25 lines
781 B
TypeScript
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,
|
|
);
|
|
}
|