async function cloneChannel(
  channelId,
  reason,
) {
  const channelToClone = await cacheHandlers.get("channels", channelId);
  if (!channelToClone) throw new Error(Errors.CHANNEL_NOT_FOUND);
  //Check for DM channel
  if (
    channelToClone.type === DiscordChannelTypes.DM ||
    channelToClone.type === DiscordChannelTypes.GroupDm
  ) {
    throw new Error(Errors.CHANNEL_NOT_IN_GUILD);
  }
  const createChannelOptions = {
    ...channelToClone,
    name: channelToClone.name,
    topic: channelToClone.topic || undefined,
    parentId: channelToClone.parentId
      ? bigintToSnowflake(channelToClone.parentId)
      : undefined,
    permissionOverwrites: channelToClone.permissionOverwrites.map((
      overwrite,
    ) => ({
      id: overwrite.id.toString(),
      type: overwrite.type,
      allow: calculatePermissions(overwrite.allow.toString()),
      deny: calculatePermissions(overwrite.deny.toString()),
    })),
  };
  //Create the channel (also handles permissions)
  return await helpers.createChannel(
    channelToClone.guildId,
    createChannelOptions,
    reason,
  );
}
/** Create a copy of a channel */
Create a copy of a channel
Create a copy of a channel
async function cloneChannel(
  channelId,
  reason,
) {
  const channelToClone = await cacheHandlers.get("channels", channelId);
  if (!channelToClone) throw new Error(Errors.CHANNEL_NOT_FOUND);
  if (
    channelToClone.type === DiscordChannelTypes.DM ||
    channelToClone.type === DiscordChannelTypes.GroupDm
  ) {
    throw new Error(Errors.CHANNEL_NOT_IN_GUILD);
  }
  const createChannelOptions = {
    ...channelToClone,
    name: channelToClone.name,
    topic: channelToClone.topic || undefined,
    parentId: channelToClone.parentId
      ? bigintToSnowflake(channelToClone.parentId)
      : undefined,
    permissionOverwrites: channelToClone.permissionOverwrites.map((
      overwrite,
    ) => ({
      id: overwrite.id.toString(),
      type: overwrite.type,
      allow: calculatePermissions(overwrite.allow.toString()),
      deny: calculatePermissions(overwrite.deny.toString()),
    })),
  };
  return await helpers.createChannel(
    channelToClone.guildId,
    createChannelOptions,
    reason,
  );
}
async function cloneChannel ( channelId , reason , ) { const channelToClone = await cacheHandlers . get ( "channels" , channelId ) ; if ( ! channelToClone ) throw new Error ( Errors . CHANNEL_NOT_FOUND ) ; if ( channelToClone . type === DiscordChannelTypes . DM || channelToClone . type === DiscordChannelTypes . GroupDm ) { throw new Error ( Errors . CHANNEL_NOT_IN_GUILD ) ; } const createChannelOptions = { ... channelToClone , name : channelToClone . name , topic : channelToClone . topic || undefined , parentId : channelToClone . parentId ? bigintToSnowflake ( channelToClone . parentId ) : undefined , permissionOverwrites : channelToClone . permissionOverwrites . map ( ( overwrite , ) => ( { id : overwrite . id . toString ( ) , type : overwrite . type , allow : calculatePermissions ( overwrite . allow . toString ( ) ) , deny : calculatePermissions ( overwrite . deny . toString ( ) ) , } ) ) , } ; return await helpers . createChannel ( channelToClone . guildId , createChannelOptions , reason , ) ; }
Create a copy of a channel
Create a copy of a channel
//Check for DM channel //Create the channel (also handles permissions)